Skip to content

Commit b98f12e

Browse files
authored
Add an option to show library classes' graphs in visualization (#947)
1 parent 126f420 commit b98f12e

File tree

2 files changed

+17
-3
lines changed
  • utbot-framework/src/main/kotlin/org/utbot/engine/selectors/strategies
  • utbot-framework-api/src/main/kotlin/org/utbot/framework

2 files changed

+17
-3
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

+7
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ object UtSettings : AbstractSettings(
123123
*/
124124
val copyVisualizationPathToClipboard get() = useDebugVisualization
125125

126+
/**
127+
* Set the value to true to show library classes' graphs in visualization.
128+
*
129+
* False by default.
130+
*/
131+
val showLibraryClassesInVisualization by getBooleanProperty(false)
132+
126133
/**
127134
* Method is paused after this timeout to give an opportunity other methods
128135
* to work

utbot-framework/src/main/kotlin/org/utbot/engine/selectors/strategies/GraphViz.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.utbot.engine.isReturn
1111
import org.utbot.engine.selectors.PathSelector
1212
import org.utbot.engine.stmts
1313
import org.utbot.framework.UtSettings.copyVisualizationPathToClipboard
14+
import org.utbot.framework.UtSettings.showLibraryClassesInVisualization
1415
import soot.jimple.Stmt
1516
import soot.toolkits.graph.ExceptionalUnitGraph
1617
import java.awt.Toolkit
@@ -103,7 +104,11 @@ class GraphViz(
103104
graph.allEdges.forEach { edge ->
104105
val (edgeSrc, edgeDst, _) = edge
105106

106-
if (stmtToSubgraph[edgeSrc] !in libraryGraphs && stmtToSubgraph[edgeDst] !in libraryGraphs) {
107+
val srcInLibraryMethod = stmtToSubgraph[edgeSrc] in libraryGraphs
108+
val dstInLibraryMethod = stmtToSubgraph[edgeDst] in libraryGraphs
109+
val edgeIsRelatedToLibraryMethod = srcInLibraryMethod || dstInLibraryMethod
110+
111+
if (!edgeIsRelatedToLibraryMethod || showLibraryClassesInVisualization) {
107112
dotGlobalGraph.addDotEdge(edge)
108113
}
109114
}
@@ -143,8 +148,10 @@ class GraphViz(
143148
}
144149

145150
// Filter library methods
146-
uncompletedStack.removeIf { it.name in libraryGraphs }
147-
fullStack.removeIf { it.name in libraryGraphs }
151+
if (!showLibraryClassesInVisualization) {
152+
uncompletedStack.removeIf { it.name in libraryGraphs }
153+
fullStack.removeIf { it.name in libraryGraphs }
154+
}
148155

149156
// Update nodes and edges properties
150157
dotGlobalGraph.updateProperties(executionState)

0 commit comments

Comments
 (0)