Get Method call's parameter type in Custom check!

16 views
Skip to first unread message

Piyush Khapekar

unread,
Aug 29, 2017, 1:35:53 PM8/29/17
to checkstyle
Hello Checkstyle Developers,

In one of my custom check-style rule, I want to get the parameter type of a calling method. for instance, I am calling test("abc") in class A so I want to retrieve the parameter type of test() method (here in our case params "abc" is of  String type, so I want to retrieve data type of "abc" i.e String). So can you guys please suggest me the best possible approach?

Thanks in advance!

Roman Ivanov

unread,
Aug 29, 2017, 5:12:59 PM8/29/17
to Piyush Khapekar, checkstyle
Hi,

unfortunately completely impossible

You cannot determine the type of an expression. Example: "getValue() + getValue2()"
You cannot determine the full inheritance hierarchy of type.
You cannot see the content of other files. You have content of one file only during all Checks execution. All files are processed one by one.

All you have is tree of strings values. Types are available in tools like findbugs,idea inspections,  ...


​thanks,
Roman Ivanov
Reply all
Reply to author
Forward
0 new messages