Author Topic: New AStyle plugin  (Read 16523 times)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
New AStyle plugin
« on: July 01, 2005, 07:41:50 pm »
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

Offline Urxae

  • Regular
  • ***
  • Posts: 376
New AStyle plugin
« Reply #1 on: July 01, 2005, 08:13:15 pm »
Wouldn't it be better to create a patch against Code::Blocks CVS and submit it?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
New AStyle plugin
« Reply #2 on: July 01, 2005, 08:59:54 pm »
Quote from: fvbommel
Wouldn'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...

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
New AStyle plugin
« Reply #3 on: July 02, 2005, 07:38:57 am »
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
Code
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"
Code
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 '}'
Code
namespace foospace {
    int Foo() {
        if (isBar) {
            bar();
            return 1;
        }   <<<<<<<<<<<<<<<<<<<<<missing
        else
            return 0;
    }
}

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
New AStyle plugin
« Reply #4 on: July 02, 2005, 09:34:53 am »
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

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
New AStyle plugin
« Reply #5 on: July 02, 2005, 10:35:12 am »
Quote from: Ceniza
Thanks for your feedback.

Thanks for your update, works fine now !

Quote from: Ceniza
I'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...

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
New AStyle plugin
« Reply #6 on: July 02, 2005, 01:29:42 pm »
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

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
New AStyle plugin
« Reply #7 on: July 02, 2005, 06:40:30 pm »
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, ...).

Quote
Btw. 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

Quote
Thanks for your update, works fine now !


Glad to read it :)

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


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

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
New AStyle plugin
« Reply #8 on: July 02, 2005, 09:05:28 pm »
Quote
New files: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle-020705.zip

CVS updated. Thanks :)

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

jochen

  • Guest
Re: New AStyle plugin
« Reply #9 on: February 21, 2006, 02:38:33 pm »
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