Graph Buddy - an interactive code dependency browsing and visualization tool

Krzysztof Borowski

Bartosz Baliś

Tomasz Orzechowski

Software development reality

  1. Growing code bases and fast changing requirements.
  2. Code quality degradation.
  3. Increasing cognitive load.
  4. Wasted time on software comprehension process.
  5. Wasted money and developers dissatisfaction.

we argue that helping the programmer with code understanding increasingly becomes one of the most essential factors in software development

Modern IDE

what we have now

Rich text editor 

Call hierarchy in IDE

IDE problems

  • Hidden semantic code connections.
  • One method context only.
  • Hard to answer reachability questions.

Objective - create a tool which:

  • can speed up code dependency understanding,
  • is capable of answering various reachability problems,
  • is strictly connected to the source code,
  • is integrated within developers' workflow,
  • is broadly available.

Which abstract model can be used?

Abstract Syntax Tree

while b ≠ 0:
    if a > b:
        a := a - b
    else:
        b := b - a
return a

Code Property Graph

CFG + PDG + AST

Representing semantic code dependencies

class A()
object AFactory {
  def createA() = {
    new A()
  }
}

Semantic Code Graph

G_{SCG}=(V_D, E_R)
  • \(V_D\) a set of vertices representing all code declarations, e.g., classes, methods, variables;
  • \({E_R\displaystyle \subseteq \{(x,y)\mid (x,y)\in V_D^{2}\; \}}\), a set of edges which are ordered pairs of nodes representing relations between nodes, e.g., call, declaration, override, inheritance, or return type.
  • required properties: type, displayName, location

Semantic Code Graph - example

class A() {
  def runA(): Unit = ...
  def run(): Unit = ...
}
object AFactory {
  def createA() = {
    new A()
  }
}

def main() = {
  AFactory.createA().runA()
}

SCG output format

syntax = "proto3";

message Location {
    string uri = 1;
    int32 startLine = 2;
    int32 startCharacter = 3;
    int32 endLine = 4;
    int32 endCharacter = 5;
}

message Edge {
    string to = 1;
    string type = 2;
    Location location = 3;
    map<string, string> properties = 4;
}

message GraphNode {
    string id = 1;
    string kind = 2;
    Location location = 3;
    map<string, string> properties = 4;
    string displayName = 5;
    repeated Edge edges = 6;
}

message SemanticGraphFile {
    string uri = 1;
    repeated GraphNode nodes = 2;
}

Graph Buddy - IDE plugins

https://plugins.jetbrains.com/plugin/13467-graph-buddy

https://marketplace.visualstudio.com/items?itemName=virtuslab.graph-buddy

Graph Buddy - IDE plugin

Providing interactive broad context

Call hierarchy

Find path

Presenting parts of the system

Thank you!

https://graphbuddy.virtuslab.com/

Made with Slides.com