Approach to finding the line number where a Method is declared

Hi everybody, I currently am trying to highlight a method declaration inside of Java source code. I am using SQ 7.9.1 LTS. The information I have present is the class name and the method name, is there a standard approach to find the a method declaration with just the method name and the class name.
What I think the approach would be is to use the Sonar maven Scanner where once I get to the file with the same class name as the file name I can then search that file for the method declaration.
Is this the correct train of thought and if not what would you recommend?
My end goal is to have the method the method declaration to be highlighted which requires line numbers. I am hopping there is some way to discover that line number then highlight.

Depends of what you mean by Highlighting.

From how I see it, the best approach here would be to use a java-based custom-rule, relying on the SonarJava plugin for parsing Java files, and triggering a dedicated, custom-made, rule (see tutorial and examples). Of course, it depends of what you want to achieve once you found the method you are searching for, but assuming it would be to “raise some issues” based on some criteria, then that would be the perfect place to start.

If you only need the line number, everything will be available in the AST provided by SonarJava (for instance, from the method name node in the tree, you can get to the identifier and the line of the corresponding token).

You may also need parameters, tacking into account overloading.

Awesome thanks so much for that! Right now I would like to underline and display some information about that method and put up a link maybe(not totally sure about the UI layout yet but def need it). But I think highlighting just the method declaration is enough for now until my api changes a bit more where I could then create Rules dynamically.
Cheers and thanks again