Author Topic: C++0x autocomplete  (Read 21919 times)

Offline Halan

  • Multiple posting newcomer
  • *
  • Posts: 43
C++0x autocomplete
« on: December 30, 2011, 06:21:57 pm »
Hey Guys,

does the Autocomplete-Plugin already support C++0x? On my machine it for example doesn't indent blocks like "for(auto x : list)" properly.

greetings,
Halan

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: C++0x autocomplete
« Reply #1 on: January 02, 2012, 07:05:35 am »
This indents as expected on my computer.
Are you using a nightly?  How does what actually happens differ from what you expected to happen?

Offline Halan

  • Multiple posting newcomer
  • *
  • Posts: 43
Re: C++0x autocomplete
« Reply #2 on: January 22, 2012, 01:19:58 am »
Are you sure it's working properly on your machine?

With the latest stable it doesn't get indented at all, with the latest nightly it gets one tab less indented as expected...

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: C++0x autocomplete
« Reply #3 on: January 22, 2012, 10:25:21 pm »
I am not sure if I completely understand what (or even if) the problem is; could you please:
a.  Post a snippet of code that you enter.  (Using code tags.)
b.  Post a snippet of code showing what (if anything) Code::Blocks does to change/auto-format it.  (Using code tags.)
and
c.  Post a snippet of code showing what it is you would have liked Code::Blocks to have changed/auto-formatted it to.  (And again, using code tags.)

I am willing to look into this when I have time (I have messed around with that part of the code recently :), so I think I know my way around it), but simply do not know what I am supposed to be trying to fix it to do.

Offline Halan

  • Multiple posting newcomer
  • *
  • Posts: 43
Re: C++0x autocomplete
« Reply #4 on: March 17, 2012, 03:19:02 pm »
Looks at this source code for example

Code
{
bool ok = true;

for(auto it: events)
ok = ok && this->subscribeEvent(elem, it);

return ok;
}

The for-loop isn't indented correctly..

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: C++0x autocomplete
« Reply #5 on: March 18, 2012, 12:16:08 am »
Now I understand.  Try the following patch.
Code
Index: src/plugins/astyle/astyle/ASBeautifier.cpp
===================================================================
--- src/plugins/astyle/astyle/ASBeautifier.cpp (revision 7900)
+++ src/plugins/astyle/astyle/ASBeautifier.cpp (working copy)
@@ -2373,9 +2373,9 @@
  tabCount += classInitializerTabs;
  }
 
- else if (isJavaStyle() && lastLineHeader == &AS_FOR)
+ else if ((isJavaStyle() || isCStyle()) && lastLineHeader == &AS_FOR)
  {
- // found a java for-each statement
+ // found a java/C++0x for-each statement
  // so do nothing special
  }
 

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: C++0x autocomplete
« Reply #6 on: March 18, 2012, 02:49:41 am »
I suggest OP give us a step by step instructions, so we won't guess.
It should related to CodeCompletion OR cbEditor,  not astyle, right?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: C++0x autocomplete
« Reply #7 on: March 18, 2012, 03:30:21 am »
The AStyle plugin was the only thing I could get to reproduce this behavior.  (Although the lack of steps is why it took me some time to track it down.)

Offline Halan

  • Multiple posting newcomer
  • *
  • Posts: 43
Re: C++0x autocomplete
« Reply #8 on: March 23, 2012, 08:25:34 pm »
Yeah I am using the AStyle formatter. Didn't even know there were other sourcecode-formatters in Code::Blocks.

And sorry, I thought my last post made the behaviour clear..

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: C++0x autocomplete
« Reply #9 on: March 25, 2012, 08:57:28 pm »
@Developers:  The patch in my previous post appears to solve the problem (although it would probably be best if the OP could confirm this as well).  Is this something that should be submitted to Code::Block's patch tracker, or to the actual AStyle project?  (If it is the AStyle project, could someone who already has a SourceForge account submit it there - I do not really want to create an account just for a single action.)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: C++0x autocomplete
« Reply #10 on: March 26, 2012, 07:07:33 am »
Is this something that should be submitted to Code::Block's patch tracker, or to the actual AStyle project?
This is astyle, not Code::Blocks. However, you should first look at the astyle code whether this has probably been fixed already. You can integrate later versions of astyle easily into Code::Blocks, just make sure you keep these two methods in the public section:
      void setBlockIndent(bool state);
      void setBracketIndent(bool state);
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: C++0x autocomplete
« Reply #11 on: March 28, 2012, 12:34:08 am »
However, you should first look at the astyle code whether this has probably been fixed already.
You were right; I checked the AStyle project, and it appears this problem has already been fixed.  Patch #3268 updates Code::Blocks to this.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: C++0x autocomplete
« Reply #12 on: March 28, 2012, 06:48:29 am »
Patch #3268 updates Code::Blocks to this.
You don't need to provide patches - I am maintaining this already, but thanks anyways.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: C++0x autocomplete
« Reply #13 on: March 28, 2012, 08:17:20 pm »
OK.

Offline Halan

  • Multiple posting newcomer
  • *
  • Posts: 43
Re: C++0x autocomplete
« Reply #14 on: May 12, 2012, 11:18:57 am »
Just wondering, is this commited upstream now?

I am using the packages from Jens' repository and I still have this formatting issue :/