Articles about extracting data from code, analyze it and programmatically transform it. In other words we talk about static analysis, automated refactoring, and code generation.

Extracting JavaDoc documentation from source files using JavaParser

A lot of people are using JavaParser for the most different goals. One of these is extracting documentation. In this short post we will see how you can print all the JavaDoc comments associated to classes or interfaces. Code is available on GitHub: https://github.com/ftomassetti/javadoc-extractor Getting all the Javadoc comments for classes We are reusing DirExplorer, a supporting […]

Implementing Lexical Preservation for JavaParser

Many users of JavaParser are asking to implement lexical preservation, i.e., the ability of parsing a Java source file, modifying the AST and get back the modified Java source code keeping the original layout. Currently this is not supported by JavaParser: you can parse all Java 8 code with JavaParser, get an AST but then the […]

Observers for AST nodes in JavaParser

We are getting closer to the first Release Candidate for JavaParser 3.0. One of the last features we added was support for observing changes to all nodes of the Abstract Syntax Tree. While I wrote the code for this feature I received precious feedback from Danny van Bruggen (a.k.a. Matozoid) and Cruz Maximilien. So I […]

Interview with Erik Dietrich on Static Analysis and a data driven approach to refactoring

Erik Dietrich is a well known Software Architect with a long experience in consulting. His blog (DaedTech) is a source of thoughtful insights on software development. In particular I was very interested by his usage of static analysis and code metrics in his consulting work. I am myself a relatively young consultant and I thought […]

Generate diagrams from C# source code using Roslyn

Beyond the source code Last week we have seen how to use Roslyn to rewrite source code to your liking. That’s all well and good, but it’s not the only thing you can do when you have a compiler open and ready to do your bidding. Another possibility is to leverage the knowledge that the […]

Resolve method calls in Java code using the JavaSymbolSolver

Why I created the java-symbol-solver? A few years ago I started using JavaParser and then I started contributing. After a while I realized that many operations we want to do on Java code cannot be done just by using the Abstract Syntax Tree produced by a parser, we need also to resolve types, symbols and […]

Python reflection: how to list modules and inspect functions

  Recently I have been playing with some ideas about applying static analysis to Python and building a Python editor in Jetbrains MPS. To do any of this I would need to first build a model of Python code. Recently we have seen how to parse Python code, however we still need to consider all […]

Getting started with JavaParser: analyzing Java Code programmatically

One of the things I like the most is to parse code and to perform automatic operations on it. For this reason I started contributing to JavaParser and created a couple of related projects: java-symbol-solver and effectivejava. As a contributor of JavaParser I read over and over some very similar questions about extracting information from Java source code. For this […]

Walkmod: automatically refactor code to apply code conventions

Walkmod: Automatically Refactor Code to Apply Code Conventions

I am very interested in tools which support the software development process, making automatic the boring bits. One system which permits to go in that direction is Walkmod: a smart tool which can refactor Java projects and enforce code conventions. It is a quite powerful tool and it should ges more and more attention. TL; DR: Tools […]

How to build a symbol solver for Java, in Clojure

How to Build a Symbol Solver for Java, in Clojure

Last week we have seen how to build models of Java code from source and JAR files. Now we want to be able to solve symbols: in practice we want to link the symbol references in our source code to symbol declarations either in Java source files or jar files. This process is called symbol […]