I am the one who wrote this example and in fact it is messy in many ways.
Short answer to your question is : no major trouble with version 4.1, get latest version of example (corrected a few minutes ago) and you should be fine : https://github.com/SonarSource/sonar-examples/tree/master/plugins/java-custom-rules
To understand what was happening:
The AST in the java plugin is an API that is not complete. In order to provide a nice way to visualize the AST I provided a PrinterVisitor
in the example and intended to display line numbers associated with the nodes (hence the cast into JavaTree
) however I messed up with the dependency and this raise the trouble you encountered (basically, not loading the class from the correct dependency), moreover the trouble is that in order to get this line I had to leak the ASTNode
abstraction into this example and this is definitely not intended to be part of public API.
Therefore the quick correction here was to remove this display of line number to make this example works correctly. The longer correction will take some more time to think of the best API design for this need. We plan to make PrinterVisitor have its way back in public API at some point of time.