Sourcetrail 2018.3

Author: Eberhard Gräther

Sourcetrail 2018.3 brings new usability features for faster source code exploration. Users can continue to browse while reindexing in the background. A graph legend and new node actions have been added to the graph visualization. The code view was extended with a local reference navigation. Project setup now supports Sonargraph and Code::Blocks project import.

Sourcetrail's indexing dialog can now be hidden to continue browsing while reindexing.

This images shows the cinder::Sphere class of the Cinder codebase, which you can download as pre-indexed Sourcetrail sample project from our download page.

New in this Release:

  • General: keep browsing while indexing; project setup from Sonargraph and Code::Blocks (.cbp) projects;
  • Graph View: graph legend; export as SVG; “show definition” and “colapse/expand” context menu actions for nodes;
  • Code View: automatic horizontal scroll to active source location; local reference navigation for local symbols and multiple edge references;
  • Tooltips: Show function and method signatures as declared in the source code.
  • C/C++: Hoverable brace begin and end locations; improved indexer performance;
  • Java: Added support for Java 9 and 10;

You can download Sourcetrail 2018.3 here. The full changelog is available here. Going more into detail, I will outline the most important features new to this release and show a few examples below.


Partnership with hello2morrow and Project Setup from Sonargraph Projects

A couple months ago we got to know the founder of hello2morrow. Their company is developing the Sonargraph static code analyzer. He shared his valuable experiences in leading a software tooling company with us and we decided to start partnership.

Project setup from Sonargraph project.

With this new release we support project setup from Sonargraph projects for C, C++ and Java. This makes it easy for anyone who already configured a Sonargraph project to start using Sourcetrail.

Project Setup from Code::Blocks Projects (.cbp)

With the new release we also added C and C++ project setup from Code::Blocks .cdp project files. This is a format that is also used by the QtCreator when importing a CMake project, so this is a good way to do project setup for Qt projects if you don’t have a Clang Compilation Database file available.

Project setup from Code::Blocks project.

Project Setup for C++ Video

We recently released a video on project setup for C++ projects which shows you best practices on how to setup a Sourcetrail project for your C++ codebase. It shows how setup from Clang Compilation Database works and also explains strategies on how to deal with errors during manual project setup.


Sourcetrail project setup for C++ video.


Continue Browsing while Indexing

So far the UI of Sourcetrail was disabled while indexing. Now we added the functionality to hide the indexing dialogs and allow the user to continue browsing the old project state while Sourcetrail is reindexing files in the background. As an additional benefit of this change we now also allow the user to revert the state of the index after indexing has been aborted. With this change we also added a progress bar to the status bar at the bottom of the window to inform the user about the current state of the indexer. Clicking on the progress bar will show the indexing dialog again.

Hide button in the indexing dialog and progress bar in the status view.

Graph View

Show Definition of Graph Node

So far Sourcetrail could only show the definition of a node if you activated it via a click in the graph or code view, or searching for it. So whenever you wanted to see the definition of a symbol you had to change the active symbol. If you wanted to see the definition of multiple symbols within one graph layout, you constantly had to activate and then go back again, which is time consuming.

The new Show Definition action in the context menu of the graph allows you to show the definition of any symbol in the code view, without activating the symbol. If no definition for the symbol is found, Sourcetrail will show the first declaration of it and otherwise nothing.

You can also use this feature by holding down Ctrl or Cmd and then clicking the node.

Collapse/Expand of Graph Node

Similarily it was sometimes annoying when you looked at classes with lots of members and you wanted to collapse the class again, you had to scroll up all the way to the top of the class to hit the collapse button.

This is now possible from the graph context menu by using the Collapse Node and the Expand Node actions. You can also use this feature by holding down Shift and then clicking the node.

Graph context menu with the new 'Expand Node' and 'Show Definition' actions.

Graph Legend

Some users export graph images from Sourcetrail and add them to their software documentation. This raises the problem that other readers who are not familiar with Sourcetrail don’t understand what the different nodes and edges mean. So far, the only places where we provided this information was within the tooltips in the graph view and in our documentation.

The new graph legend can be activated with the ? button in the lower right corner of the graph view or by entering the legend keyword in the search field. The graph legend gives an overview about the different node and edge types, as well as graph layouts. The legend can also be exported as image just like every other graph diagram.

Full graph legend.

Export Graph as SVG

Some users complained that our graph image export has a constrained resolution and doesn’t allow for scaling exported images to larger sizes. With this release it is now also possible to export the graph in the SVG format.

Code View

Local Reference Navigation

One of the great things about Sourcetrail is that it knows all locations where a certain symbol is referenced and makes it easy to look at all of them. However, this was not so easy for scope local symbols and whenever a symbol was referenced multiple times within the same function or method e.g. when a function is calling another function multiple times.

In these cases the code view highlighted all of the references, but as a user you couldn’t tell at a glance how many times the symbol was referenced. With functions that have many lines of code you even had to scroll up and down to make sure you don’t miss a location where a local symbol is accessed.

Local reference navigation for local symbols.

To solve this problem we introduced the new local reference navigation, which will be displayed on demand in the code view navigation bar at the top of the view. It shows you how often a symbol is referenced within the local scope and allows for navigation between the references.

Automatic Scroll to Horizontal Position of Source Location

So far we only scrolled the code view vertically when navigating from one reference in the code view to the next. But sometimes source references are also horizontally outside of the visible area. With the new release we also make sure that the code view changes its horizontal scroll position to make the current reference visible.

Improved Signatures in Tooltips

When hovering a function or method in the graph or code view, Sourcetrail will show you a tooltip containing the full signature with return type and all parameter types. But so far we showed the signatures the way they were generated and used by our indexer, which did not include parameter names. Also types got resolved to their underlying type and often looked different than in the declaration of the function.

Signatures before - taken from the indexer

With this release we show function and method signatures exactly the way they were declared in the code. This improves readability of the signatures, because they look just like in the source code.

Signatures after - taken from the source code

Closing comments

Thanks for reading, we hope that you like our progress! Don’t forget to download the new release build.

Follow us: mail - Twitter - Facebook - Google+

Const - Friend or Foe in C++?

This post outlines different views on the const keyword and give some hints on how to use this keyword to improve the overall quality and the maintainability of a code base. Continue reading

Sourcetrail 2018.2

Published on April 23, 2018

Sourcetrail 2018.1

Published on January 29, 2018