Stop code reformatting when compiling?

How can I stop IDEA from reformatting my source code when I compile with
Ctrl-F9? I've looked through the IDE settings and haven't been able to
find anything.

-cr

5 comments
Comment actions Permalink

Cory R wrote:

How can I stop IDEA from reformatting my source code when I compile with
Ctrl-F9? I've looked through the IDE settings and haven't been able to
find anything.

-cr


Whoops- I meant Ctrl-Shift-F9. I'm using IDEA 6.0.1.

Thanks.

0
Comment actions Permalink

Hello Cory,

CR> How can I stop IDEA from reformatting my source code when I compile
CR> with Ctrl-F9? I've looked through the IDE settings and haven't been
CR> able to find anything.

There is no option in IDEA for such behavior. Please ensure that your keymap
is correctly configured and try uninstalling third-party plugins.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Dmitry Jemerov wrote:

There is no option in IDEA for such behavior. Please ensure that your
keymap is correctly configured and try uninstalling third-party plugins.


Will you try this then?

Create a GUI form and java class. Add a couple of buttons to it.
Make the java code look something like the code below (I added only the
main function). Before compiling, the main() has two while loops, each
on a single line. Now hit Ctrl-Shift-F9. On my machine IDEA reformats
the while loops to look like:
while (++i < 5) {
}
while (++i < 10) {
}
I have no third party plugins and I have removed about half the ones
that are installed by default. Does the same thing happen on your machine?

I'm running 6.0.1 on Ubuntu 6.

-cory



public class TestForm {
private JButton button1;
private JButton button2;

public static void main(String[] args) {
int i = 0;
while (++i < 5) { }
while (++i < 10) { }
}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE
$$$setupUI$$$();
}

/**

  • Method generated by IntelliJ IDEA GUI Designer

  • >>> IMPORTANT!! <<<

  • DO NOT edit this method OR call it in your code

*

  • @noinspection HardCodedStringLiteral

*/
private void $$$setupUI$$$() {
final JPanel panel1 = new JPanel();
panel1.setLayout(new
com.intellij.uiDesigner.core.GridLayoutManager(2, 3, new Insets(0, 0, 0,
0), -1, -1));
button1 = new JButton();
button1.setText("Button");
panel1.add(button1, new
com.intellij.uiDesigner.core.GridConstraints(0, 2, 1, 1,
com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK |
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null,
null, null, 0, false));
final com.intellij.uiDesigner.core.Spacer spacer1 = new
com.intellij.uiDesigner.core.Spacer();
panel1.add(spacer1, new
com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1,
com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, 1,
null, null, null, 0, false));
final com.intellij.uiDesigner.core.Spacer spacer2 = new
com.intellij.uiDesigner.core.Spacer();
panel1.add(spacer2, new
com.intellij.uiDesigner.core.GridConstraints(1, 0, 1, 1,
com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
com.intellij.uiDesigner.core.GridConstraints.FILL_VERTICAL, 1,
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
button2 = new JButton();
button2.setText("Button");
panel1.add(button2, new
com.intellij.uiDesigner.core.GridConstraints(1, 1, 1, 1,
com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK |
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null,
null, null, 0, false));
}
}


0
Comment actions Permalink

Hello Cory,

>> There is no option in IDEA for such behavior. Please ensure that your
>> keymap is correctly configured and try uninstalling third-party
>> plugins.
>>
CR> Will you try this then?

Ah, you should have mentioned that you're using GUI Designer source code
generation. This is indeed a problem in IDEA.
http://www.jetbrains.net/jira/browse/IDEADEV-11285

CR>
CR> Create a GUI form and java class. Add a couple of buttons to it.
CR> Make the java code look something like the code below (I added only
CR> the
CR> main function). Before compiling, the main() has two while loops,
CR> each
CR> on a single line. Now hit Ctrl-Shift-F9. On my machine IDEA
CR> reformats
CR> the while loops to look like:
CR> while (++i < 5) {
CR> }
CR> while (++i < 10) {
CR> }
CR> I have no third party plugins and I have removed about half the ones
CR> that are installed by default. Does the same thing happen on your
CR> machine?



--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

I didn't realize it was related to the gui designer until I tried to
make a small test case.

Thanks for looking at this.

Cory

Dmitry Jemerov wrote:

Hello Cory,

>>> There is no option in IDEA for such behavior. Please ensure that your
>>> keymap is correctly configured and try uninstalling third-party
>>> plugins.
>>>

CR> Will you try this then?

Ah, you should have mentioned that you're using GUI Designer source code
generation. This is indeed a problem in IDEA.
http://www.jetbrains.net/jira/browse/IDEADEV-11285

CR> CR> Create a GUI form and java class. Add a couple of buttons to it.
CR> Make the java code look something like the code below (I added only
CR> the
CR> main function). Before compiling, the main() has two while loops,
CR> each
CR> on a single line. Now hit Ctrl-Shift-F9. On my machine IDEA
CR> reformats
CR> the while loops to look like:
CR> while (++i < 5) {
CR> }
CR> while (++i < 10) {
CR> }
CR> I have no third party plugins and I have removed about half the ones
CR> that are installed by default. Does the same thing happen on your
CR> machine?


0

Please sign in to leave a comment.