Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: Zlika on September 23, 2005, 11:33:21 pm

Title: New plugin! (Code Statistics)
Post by: Zlika on September 23, 2005, 11:33:21 pm
Hi everybody!
During a long time, I was looking for an IDE which can count the code/comments lines of a project. I haven't found one (maybe in a commercial IDE...). So I have found small command-line programs able to do that, but it was not very convenient.

That's why I'm proud to announce you the release of a first version of a small "Code Statistics" plugin.
It can count the code/comments/empty lines of the files of the current project. Languages supported for the moment are C/C++, java and Python. In a future release, users will be able to add their own language settings.

You can find the plugin here: http://membres.lycos.fr/exoguard/

Zlika
Title: Re: New plugin! (Code Statistics)
Post by: darklordsatan on September 24, 2005, 12:10:11 am
Good! I see you're into developing plugins for C::B, thats really neat  :D
Title: Re: New plugin! (Code Statistics)
Post by: squizzz on September 24, 2005, 11:36:36 am
Nice plugin!

Additional idea for line statistics: avg lines per file.

If you plan further development of this plugin, you might consider measuring also size of the source files: (it might be a new tab already)
- size (in bytes) of the source files ("w00t, this code is getting ~200K")
- amount of source files
- amount of headers
- size of implementation (*.cpp)
- size of headers (*.h)
- avg size of *.cpp file (also the biggest and the smallest file)
- avg size of *.h file

Thanks for the plugin
Title: Re: New plugin! (Code Statistics)
Post by: Zlika on September 24, 2005, 01:03:53 pm
Thanks for your comments.
It's interesting ideas for the next releases!

Zlika
Title: Re: New plugin! (Code Statistics)
Post by: mandrav on September 25, 2005, 02:30:20 pm
This plugin has been added in CVS, in the contrib plugins section.
Zlika is now a registered Code::Blocks Plugin Developer.

Very well done, Zlika :)
Title: Re: New plugin! (Code Statistics)
Post by: David Perfors on September 25, 2005, 02:53:07 pm
It is probably very nice, but... could you make it Unicode compatible?
Title: Re: New plugin! (Code Statistics)
Post by: mandrav on September 25, 2005, 04:33:28 pm
*EDITED*

You are right, sorry about that. Fixed it in CVS.
Title: Re: New plugin! (Code Statistics)
Post by: Zlika on September 25, 2005, 05:20:04 pm
There are plenty of empty lines in the sources when I view them with CB.
When I look the text files with an hex editor, I can see each end of line is: CR-CR-LF !
Is it a bug of CB when you edit a file under Unix and then Windows?

Zlika
Title: Re: New plugin! (Code Statistics)
Post by: mandrav on September 25, 2005, 05:30:52 pm
Yes, sometimes it can happen (depends on the editor used, etc - some files I quickly edit with other editors, not CB).
If you see this, and it's more than a couple of lines (where you could just fix it yourself by deleting them), run dos2unix on the files before editing them and all will be fine again.
Title: Re: New plugin! (Code Statistics)
Post by: Pecan on October 23, 2005, 08:41:20 pm
Zlika,

Thanks for the nice plugin. Good example code for us novices.
I noticed (on my win xp sp2 system) that Codestat::Configure()
isn't being called. I modified it as follows:

int CodeStat::Configure()
{
    // if not attached, exit
    asm("int3");  //?? is this function being called??
    if (!m_IsAttached)
        return -1;
   
    LanguageDef languages[NB_FILETYPES];
    LoadSettings(languages);
    CodeStatConfigDlg dlg(Manager::Get()->GetAppWindow(), languages);
      wxString msg = _("Configure called!");
      wxMessageBox(msg, _("Error"), wxICON_ERROR | wxOK);
    if (dlg.ShowModal() == wxID_OK)
    {
    }
    return 0;
}

It neither crashed at the "asm("int3")" nor did it ever produce a
message box.

What am I missing here??

Thanks
Title: Re: New plugin! (Code Statistics)
Post by: Pecan on October 24, 2005, 12:18:51 am
Zlika,

Please ignore my last message. I don't know what I'm doing.
My bad. ::Configure()  works fine.

Sorry for the false alarm,
Pecan
Title: Re: New plugin! (Code Statistics)
Post by: ikolev on May 19, 2006, 01:18:33 pm
Great plugin, thanks. Hope it will be supported in the future.

The most important addition I'd like to see is displaying statistics for all projects in the workspace, not just the active one.

Regards,
Ivan
Title: Re: New plugin! (Code Statistics)
Post by: takeshimiya on May 19, 2006, 01:28:16 pm
I have a little "refactoring" suggestion.
Move the comment tokens and file types pair, from this plugin, to the SDK; to increase reuse in other plugins: CodeCompletion, ToDo plugin, wxSmith, and any other wanting to use this information.

In the SDK, a good place to put physically the tokens are inside the xml lexers :)