Page 1 of 1

For source code, display function declaration

Posted: Wed Feb 04, 2009 4:26 pm
by Buurmas
Thanks for your great product. All our developers use Compare It!

We have been using it (among other things) for C++ code reviews. It does a great job of taking us right to the change. But then the question always follows: "Wait, what function are we in?" We page up and locate the function and then go back to the change. It would be really slick if Compare It!, when in a function block (i.e., between curly braces for C++: return_value functionname(parms){ }), could have an option to show "return_value functionname(parms)" on some toolbar.

Thanks for your consideration.

Posted: Sun Feb 08, 2009 12:47 pm
by grigsoft
Thank you for suggestion! IN fact this feature is already in my wish list for a quite long time. I will do it soon.

Thank you!

Posted: Mon Feb 09, 2009 3:01 pm
by Buurmas
Thank you! And thanks again for a very useful product.

Thinking about this more

Posted: Wed Sep 30, 2009 4:49 pm
by Buurmas
It seems like one trickiest part here is, given a line of code, identifying the preceding function. And it's language dependent. For C++, I think you want to look for a pattern like this:

ReturnValue FunctionName(*)*{

... where * are wildcards. FunctionName might be ClassName::FunctionName, but it should be one term without spaces either way. ReturnValue and FunctionName cannot contain a semicolon or parentheses or brackets. I think that is good enough to distinguish between statements like this:

if(*)*{

... as well as class or namespace designations:

class ClassName*{
namespace NameSpaceName*{

Maybe CompareIt! could simply locate this pattern appearing on or before the highlighted line of code and display it on a status bar or something. To make it language-specific and associated with the appropriate file extensions, the pattern could be entered in Options / Options / File Filters. If you wanted to make the setting broader than "function name" you could call it "context identifier" or something. You could even make it the user's responsibility to construct a regular expression to identify the pattern if you wanted.

Posted: Thu Oct 01, 2009 3:43 am
by grigsoft
That's right - but do not forget that I do full syntax coloring, so I parse file anyway. I just need to tweak it a bit.