Version: CVS (using KDE 3.4.0 Level "b" , SUSE 9.2 UNSUPPORTED) Compiler: gcc version 3.3.4 (pre 3.3.5 20040809) OS: Linux (i686) release 2.6.8-24.14-default If I select: "Settings->Configure KDevelop->Formatting->User Defined->Other Brackets=Break, Keep one-line statements, Keep one-line blocks", the code is still reformatted if I put all of a function on one line. For example: void from(T from_) { _from = from_; } becomes: void from(T from_) { _from = from_; } Which is really a bother for short accessor functions. I believe this was working correctly for a brief period, perhaps a week ago. I checked in ~.kde/share/config/kdeveloprc and found: [AStyle] KeepBlocks=true KeepStatements=true ~/.kde/share/apps/kdevastyle/kdevpart_astyle.rc has: <!DOCTYPE kpartgui> <kpartplugin library="libkdevastyle" version="2" name="KDevAStyle" > <MenuBar> <Menu name="edit" > <Action group="edit_astyle" name="edit_astyle" /> </Menu> </MenuBar> <ActionProperties> <Action shortcut="Tab" name="edit_astyle" /> </ActionProperties> </kpartplugin>
Astyle has not changed in 2 years or so. So I do not belive that it worked a week ago.
Please don't underestimate the impact of this this type of feature on the user. In the not too distant past, I procalimed I would never use oneline blocks in my code. My opinion changed when I wrote several hundred lines of glue code that looks like this: inline osg::Vec2f vec2f(const a2f_T& v) { return osg::Vec2f(v[0], v[1]); } inline osg::Vec3f vec3f(const a3f_T& v) { return osg::Vec3f(v[0], v[1], v[2]); } inline osg::Vec3f vec3fX(a3f_T a) { return vec3f(a3fX(a)); } inline osg::Vec3f vec3fY(a3f_T a) { return vec3f(a3fY(a)); } inline osg::Vec3f vec3fZ(a3f_T a) { return vec3f(a3fZ(a)); } inline osg::Vec3f vec3fXY(a3f_T a) { return vec3f(a3fXY(a)); } inline osg::Vec3f vec3fYZ(a3f_T a) { return vec3f(a3fYZ(a)); } inline osg::Vec3f vec3fXZ(a3f_T a) { return vec3f(a3fXZ(a)); } inline osg::Vec3f vec3fX(osg::Vec3f v) { return vec3fX(a3f(v)); } inline osg::Vec3f vec3fY(osg::Vec3f v) { return vec3fY(a3f(v)); } inline osg::Vec3f vec3fZ(osg::Vec3f v) { return vec3fZ(a3f(v)); } inline osg::Vec3f vec3fXY(osg::Vec3f v) { return vec3fXY(a3f(v)); } inline osg::Vec3f vec3fYZ(osg::Vec3f v) { return vec3fYZ(a3f(v)); } inline osg::Vec3f vec3fXZ(osg::Vec3f v) { return vec3fXZ(a3f(v)); } I depend on automatic formatting to keep track of syntax determined indentation. That is one of the most essential features an IDE can offer to me. If I open the above code in KDevelop and apply the reformat source command, 100 loc becomes 400 loc. What fit one one screen, now requires a lot of scrolling. If I save the code after reformatting it, then open it in Emacs, where I created it, I have no way of getting it back to the form I had short of writing some Lisp to rereformat the code, or spend a few minutes pounding on the keyboard. Much of what I would like to see in the KDevelop regarding source formatting is in the perview of AStyle, and I will take it to the AStyle developers. If KDevelop's AStyle integration is broken, I cannot determin what feature are actually missing. I'll have a look at the KDevelop code and try to determin where exactly the breakage is, and point it out so that a person qualified to fix it can easily address the problem. But I have to admit, determining the entry points into KDevelp is quite a challenge for me.
One additional comment, and this is in response to Amilcar. I do believe the feature was working briefly. That may have been due to something lingering around on my system from a previous KDevelop version. But I doubt that. What it may signify is that the problem is not in the AStyle part. It may be in KDevPlugin. I'm pretty sure the problem is that the configuration option is not being saved.
After spending hours trying to figure out how this all works, I now realize what the problem is. "No" really means "Yes". kdevelop/parts/astyle/astyle_adaptor.cpp change lines 96 and 97 from: setBreakOneLineBlocksMode(config->readBoolEntry("KeepBlocks", false)); setSingleStatementsMode(config->readBoolEntry("KeepStatements", false)); to: setBreakOneLineBlocksMode(!config->readBoolEntry("KeepBlocks", false)); setSingleStatementsMode(!config->readBoolEntry("KeepStatements", false));
Did anyone committed this change to SVN ?
No, nobody's committed it. There hasn't been a commit to KDevelop other than cmake build fixes for almost a month now.
SVN commit 556535 by geiseri: Fixed astyle adaptor is using "PadOperators" option for padding both operators and parenthesis. Bug# 121106 Fixed keep one-line blocks option does nothing. Bug# 105396 Fixed custom style preview. This was closed, but it was not working right, the preview would always be wrong. Bug# 70818 BUG: 121106 BUG: 105396 BUG: 78020 M +3 -3 astyle_adaptor.cpp M +18 -1 astyle_widget.cpp --- tags/kdevelop/3.3.91/parts/astyle/astyle_adaptor.cpp #556534:556535 @@ -90,11 +90,11 @@ // padding setOperatorPaddingMode(config->readBoolEntry("PadOperators", false)); - setParenthesisPaddingMode(config->readBoolEntry("PadOperators", false)); + setParenthesisPaddingMode(config->readBoolEntry("PadParentheses", false)); // oneliner - setBreakOneLineBlocksMode(config->readBoolEntry("KeepBlocks", false)); - setSingleStatementsMode(config->readBoolEntry("KeepStatements", false)); + setBreakOneLineBlocksMode(!config->readBoolEntry("KeepBlocks", false)); + setSingleStatementsMode(!config->readBoolEntry("KeepStatements", false)); } KDevFormatter::KDevFormatter( AStyleWidget * widget ) --- tags/kdevelop/3.3.91/parts/astyle/astyle_widget.cpp #556534:556535 @@ -138,7 +138,24 @@ void AStyleWidget::styleChanged( int id ) { - QString sample = "namespace foospace { class Bar { public: int foo(); private: int m_foo; }; int Bar::foo() { switch (x) { case 1: break; default: break; } if (isBar) { bar(); return m_foo+1; } else return 0; } }"; + QString sample = "namespace foospace {\n" + "class Bar {\n" + "public:\n" + "int foo();\n" + "private:\n" + "int m_foo;\n" + "};\n" + "int Bar::foo() {\n" + "switch (x) {\n" + "case 1:\n" + "break;\n" + "default:\n" + "break;\n" + "} if (isBar) {\n" + "bar();\n" + "return m_foo+1;\n" + "} else return 0; \n" + "}\n }\n"; ConfigTabs->setTabEnabled(tab_2, id == 0); ConfigTabs->setTabEnabled(tab_3, id == 0);
This is still broken. Here's the fix: 101,102c101,102 < setBreakOneLineBlocksMode(config->readBoolEntry("KeepBlocks", false)); < setSingleStatementsMode(config->readBoolEntry("KeepStatements", false)); --- > setBreakOneLineBlocksMode(!config->readBoolEntry("KeepBlocks", false)); > setSingleStatementsMode(!config->readBoolEntry("KeepStatements", false)); The problem is that the checkbox labels are the logical inverse of the settings they control. With: Settings->Configure KDevelop->Formatting->Formatting [x]Keep one-line statements [x]Keep one-line blocks This happens: void from(T from_) { _from = from_; } Edit->Reformat Source void from(T from_) { _from = from_; } [AStyle] BlockBreak=false BlockBreakAll=false BlockIfElse=false Brackets=Attach BracketsCloseHeaders=false FStyle=UserDefined FillCount=4 FillEmptyLines=false FillForce=true IndentBlocks=false IndentLabels=false IndentNamespaces=false IndentPreprocessors=false KeepBlocks=true KeepStatements=true PadParenthesesIn=false PadParenthesesOut=false PadParenthesesUn=false
r610450 | webb | 2006-12-04 23:21:23 +1100 (Mon, 04 Dec 2006) | 6 lines Bug: 137913 Bug: 105396 Fix applying all the options. Added more sample code to the style examples. Updated some tool tips.