find next function

If reporting a bug with the Zeus IDE please post the details here. Please do not post questions here.
Post Reply
JackR
Posts: 61
Joined: Fri Jun 16, 2006 8:50 pm

find next function

Post by JackR »

Hi Jussi,

The feature to find the next function ( control-down_arrow or control-up_arrow ) is no longer working correctly in C++ files. I'm not sure when it stopped working. It stops at many lines that aren't functions. I believe the problem is that it is stopping at any line which contains a double colon (::). I have a lot on lines in my code that have this structure

class_name::enum_constant_declared_in_class

This needs to be distinguished from a function which looks like this:

void class_name :: function_name( parameters)

Hopefully, this can be fixed because I use to love this feature.

Thanks!
Jack
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

In the general section of the document type there is a function regexp that defines what is a function.

All you need to do is create a regexp that defines the lines that are functions.

For example this regexp

Code: Select all

[a-zA-Z0-9_]+::[a-zA-Z0-9_]+\(
will identify lines of code like the following as functions

Code: Select all

void class_name::function_name( parameters)
To add more definitions just use the regep or construct:

Code: Select all

([a-zA-Z0-9_]+::[a-zA-Z0-9_]+\()|(some other regexp search)
Cheers Jussi
JackR
Posts: 61
Joined: Fri Jun 16, 2006 8:50 pm

Post by JackR »

Hi Jussi,

Thanks for the feedback, I didn't realize I could configure this. But unfortunately, this just changes the problem. I didn't do a complete job of asking my question. I want to find function definitions for C and C++ of the form

return_type class_name :: function name ( parameters )
return_type class_name :: function name ( parameters,
return_type function name ( parameters )
return_type function name ( parameters

and not find lines which call functions or have similar structures

function( parameter );
function (
if ( result > sizeof(tag) )
class_name::enum_variable

I'm not very good at regular expressions, but I don't see any way to find just the functions.

Thanks!
Jack
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi Jack,

Try this one:

Code: Select all

^[_a-z0-9]+[ &*\t]+[_a-z0-9 :\t]*[_a-z0-9]+[ \t]*[(]+.*
To test my regular expressions I just use the find dialog in Zeus itself.
I'm not very good at regular expressions
In the expression given the ^ represents the start of line, the [...] represent a set of charaters, the + means it must be found, the * means optional and the .* means any characters.

Cheers Jussi
JackR
Posts: 61
Joined: Fri Jun 16, 2006 8:50 pm

Post by JackR »

Hi Jussi,

Thanks for the help. Your solution doesn't fix the problem 100%, but it is so much better and very usable now. It still stops a prototypes of functions which is a very minor issue.

Thanks again!
Jack
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

It still stops a prototypes of functions which is a very minor issue.
Just change the regexp to be this:

Code: Select all

^[_a-z0-9]+[ &*\t]+[_a-z0-9 :\t]*[_a-z0-9]+[ \t]*[(]+.*[^;]+$
The [^;]+$ addition says ignore any line that ends in a semi-colon.

In fact since functions can be written using upper case letters the regexp should be this:

Code: Select all

^[_a-zA-Z0-9]+[ &*\t]+[_a-zA-Z0-9 :\t]*[_a-zA-Z0-9]+[ \t]*[(]+.*[^;]+$
Cheers Jussi
JackR
Posts: 61
Joined: Fri Jun 16, 2006 8:50 pm

Post by JackR »

Hi Jussi,

Thanks so much for your help. You may want to consider making this last reg ex string you provided me the C/C++ default when none is provided.

Thanks Again!
Jack
Post Reply