Unable to find the starting line number with MethodCallSyntaxDescriptor

31 views
Skip to first unread message

Arjun

unread,
Sep 5, 2023, 2:50:53 AM9/5/23
to checkstyle
Hello Checkstyle Team,

I'm working on applying rules for loggers used in the codebase. While doing so I'm unable to find the starting line number for the first parameter of the logger. Descriptor always returns the line number it is ending with.

I want to add the rule to start the logger's first parameter from its method call (i.e. 14) but I couldn't find any way to check that since the first param line number returns 17 in the below case.

example_method.PNG

int loggerLineNumber = method.getStartLineNumber();
 int firstParamLineNumber = method.getParameterList(DetailAST::getFirstChild).getLineNo();

I wanted to compare these 2 values to set the rule. But that's not happening.

Method_Call_Descriptor.PNG

Please help me out. I have already spent enough time on it.

Thanks & Regards,
Arjun

Roman Ivanov

unread,
Nov 12, 2023, 8:14:34 PM11/12/23
to Arjun, checkstyle
Sorry to late reply.

You need to report violation on specific ast token that having line and column that you need.

If you still have problems, probably you can share source code of your Check/module and we can look into it more specifically.

--
You received this message because you are subscribed to the Google Groups "checkstyle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/checkstyle/df7abe55-7807-4485-98a1-66d84ee21a7fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages