how to get the name of the method you're in?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Red_L
Posted On:   Thursday, May 3, 2001 11:48 AM

if you're in a method, I was wondering how you get the name of the method you're in? for example if you're calling this method:

public void testMethod() {
String methodName; // I want methodName to be equal to "testMethod"
}

is this possible, in a clean way?

Re: how to get the name of the method you're in?

Posted By:   Ric_Klaren  
Posted On:   Friday, May 4, 2001 01:47 AM

Guess this is Java but thought I mention
it anyway. In C++ mode you can use the
__FUNCTION__ or __PRETTY_FUNCTION__
construction (at least gcc supplies these).
I just noticed that there also might be a
__func__ predefined variable
(seems to be ISO C-99 compliant).

Another option is to include the names
in the rules yourself:


some_rule { String rule_name = "some_rule" }: bla bla;

Re: how to get the name of the method you're in?

Posted By:   Ninad_Jambhekar  
Posted On:   Thursday, May 3, 2001 12:21 PM

Throw and catch an exception and grab the method name from the stack trace.
About | Sitemap | Contact