News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

New AStyle plugin

Started by Ceniza, July 01, 2005, 07:41:50 PM

Previous topic - Next topic

Ceniza

I'm pretty sure it'sn't the most popular plugin of Code::Blocks, but when it comes handy it's good to have it working :)

The original plugin uses AStyle 1.15.3, the new plugin uses AStyle 1.17.0-dev CVS.

There was a big change that makes it easier to use: std::istream instead of the AStyle stream iterator.

The current implementation had a few problems when applying the settings, that's now fixed.

I added the Bracket type combobox so now you can decide if you want Break, Attach, Linux or None when you customize.

I hope it be accepted to replace the current CVS version.

Well, the link, of course: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle.zip

Urxae

Wouldn't it be better to create a patch against Code::Blocks CVS and submit it?

mandrav

Quote from: fvbommelWouldn't it be better to create a patch against Code::Blocks CVS and submit it?
Yes that is better for patches. But, I think, we have an exception here since he updated to the newest astyle code too (which we keep in our CVS)...

Anyway, thanks Ceniza. Your changes have been applied to CVS :)

Yiannis.
Be patient!
This bug will be fixed soon...

tiwag

With the new astyle plugin,
the indentation of if(){} blocks is wrong,
when using K&R style (at least there i found it happen),
it's indented one size too much.

this sample, reference "K&R" style
void Notify() {
   if(!m_frame->IsRunning()) {
       m_gauge->SetValue(0);
   }
   else {
       if(!m_bInit) {
           if(m_thread->GetRSSLength()) {
               m_bInit = true;
           }
       }
       else {
           m_gauge->SetValue(m_thread->GetRSSPos());
           m_frame->SetStatusText(
               wxString::Format(wxT("Converting Data...  %i of %i"),
                                m_thread->GetRSSPos(),
                                m_thread->GetRSSLength()
                               )
           );
       }
   }
}


astyled with "K&R"
void Notify() {
   if ( !m_frame->IsRunning() ) {
           m_gauge->SetValue( 0 );
       }
   else {
           if ( !m_bInit ) {
                   if ( m_thread->GetRSSLength() ) {
                           m_bInit = true;
                       }
               }
           else {
                   m_gauge->SetValue( m_thread->GetRSSPos() );
                   m_frame->SetStatusText(
                       wxString::Format( wxT( "Converting Data...  %i of %i" ),
                                         m_thread->GetRSSPos(),
                                         m_thread->GetRSSLength()
                                       )
                   );
               }
       }
}

is indented one size too much !


btw, the K&R preview-sample misses a bracket '}'
namespace foospace {
   int Foo() {
       if (isBar) {
           bar();
           return 1;
       }   <<<<<<<<<<<<<<<<<<<<<missing
       else
           return 0;
   }
}

Ceniza

Thanks for your feedback.

When I updated and "fixed" the plugin I focused in the Custom style and considered the predefined ones were right, but it seems I was wrong.

I had to enable and disable even more options to get the right results in the predifined styles. Hadn't noticed the sample was wrong for almost all of them.

I tested all the styles this time and they seem to be working as they should now.

I'd really need to make a file to test all the cases, pass it through AStyle, AStyle plugin and compare the results.

By now I'll upload the new files (just 2) which I had to modify. I'll try to make the test file later (I really need to sleep first).

I'll also include a 3rd file (the resource file) where I made a little change.

New files: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle-020705.zip

tiwag

Quote from: CenizaThanks for your feedback.
Thanks for your update, works fine now !

Quote from: CenizaI'll try to make the test file later (I really need to sleep first).
please don't hurry !  we look forward to hear from you again...

squizzz

Hey, I played a bit trying to fool Source code formatter (AStyle) plugin (finalbeta 1.0), and found nice benchmarks that make it quite easy. I thought that maybe someone also find this resource valuable, so here it goes: The 2004 Allegro ScreenHack.

Most of the sources compiles & runs if Allegro game programming library is set up.

Btw. I found one example that worked *almost* correctly (function alert  should go into single line, I suppose):
before
after
this space is for rent

Ceniza

Allegro... my old fellow :)

The ScreenHack entries really are a good source for testing, even though they won't test everything (most people uses C so it won't test namespaces, classes, ...).

QuoteBtw. I found one example that worked *almost* correctly (function alert should go into single line, I suppose):

In the original file the call to alert is split and AStyle will keep it split too with some indentation, so... it works correctly? :P

QuoteThanks for your update, works fine now !

Glad to read it :)

Quoteplease don't hurry ! we look forward to hear from you again...

Ok. When I get it done I'll comment about it here.

mandrav

Be patient!
This bug will be fixed soon...

jochen

The new AStyle plugin completely deletes lines when they contain German umlauts, e. g.

    // **für Test auf U0***************

or

        if (U1RBL==0x07) // Änderung
        {
          ...
        }

Seems this makes it unusable :-(

Any idea?

Jochen