Skip to content

Browsing Checkstyle AST Tree for Java files visually

Roman Ivanov edited this page Apr 8, 2015 · 4 revisions

There are 2 ways to show Checkstyle AST tree for a Java file:

Checkstyle AST Eclipse Viewer plugin

This is a simple plugin for Eclipse IDE which opens AST tree from right-click menu for selected Java resource.

Checkstyle Built-in AST Viewer

Checkstyle comes with Swing GUI app which shows AST tree for a given resource. To open i, you have to download latest Checkstyle jar file from http://sourceforge.net/projects/checkstyle/files/checkstyle/ (checkstyle-X.X-all.jar) and execute:

$ java -classpath checkstyle-X.X-all.jar com.puppycrawl.tools.checkstyle.gui.Main

Unix users could do all in more simple way: we have a nice shell script which shows AST tree automatically:

Usage: sevntu-checks/src/main/sh/ast.sh [<path_to_Java_file>]

Notes: when launched first time, this script downloads checkstyle-X.X-all.jar into your $TEMP dir and so, first script execution could be a bit longer then others =)

To simplify it even more, you could alias this script by adding line alias ast='< path_to_sh >' to the end of your ~/.bashrc file to let 'Show AST tree' command on your system look like ast <path_to_java_file> or just ast (which opens an empty Ast viewer window).