|
1 | 1 | package org.utbot.engine.selectors.strategies |
2 | 2 |
|
| 3 | +import mu.KotlinLogging |
| 4 | +import org.utbot.common.FileUtil.createNewFileWithParentDirectories |
3 | 5 | import org.utbot.engine.CALL_DECISION_NUM |
4 | 6 | import org.utbot.engine.Edge |
5 | 7 | import org.utbot.engine.ExecutionState |
6 | 8 | import org.utbot.engine.InterProceduralUnitGraph |
| 9 | +import org.utbot.engine.isLibraryNonOverriddenClass |
7 | 10 | import org.utbot.engine.isReturn |
8 | 11 | import org.utbot.engine.selectors.PathSelector |
9 | 12 | import org.utbot.engine.stmts |
10 | 13 | import org.utbot.framework.UtSettings.copyVisualizationPathToClipboard |
| 14 | +import soot.jimple.Stmt |
| 15 | +import soot.toolkits.graph.ExceptionalUnitGraph |
11 | 16 | import java.awt.Toolkit |
12 | 17 | import java.awt.datatransfer.StringSelection |
13 | 18 | import java.io.FileWriter |
14 | 19 | import java.nio.file.Files |
15 | 20 | import java.nio.file.Paths |
16 | | -import mu.KotlinLogging |
17 | | -import org.apache.commons.io.FileUtils |
18 | | -import org.utbot.engine.isLibraryNonOverriddenClass |
19 | | -import org.utbot.engine.isOverridden |
20 | | -import soot.jimple.Stmt |
21 | | -import soot.toolkits.graph.ExceptionalUnitGraph |
22 | 21 |
|
23 | 22 | private val logger = KotlinLogging.logger {} |
24 | 23 |
|
@@ -51,10 +50,17 @@ class GraphViz( |
51 | 50 | val classLoader = GraphViz::class.java.classLoader |
52 | 51 |
|
53 | 52 | for (file in requiredFileNames) { |
54 | | - FileUtils.copyInputStreamToFile( |
55 | | - classLoader.getResourceAsStream("html/$file"), |
56 | | - Paths.get(graphVisDirectory.toString(), file).toFile() |
57 | | - ) |
| 53 | + classLoader.getResourceAsStream("html/$file").use { inputStream -> |
| 54 | + val path = Paths.get(graphVisDirectory.toString(), file) |
| 55 | + val targetFile = path.toFile() |
| 56 | + targetFile.createNewFileWithParentDirectories() |
| 57 | + |
| 58 | + targetFile.outputStream().use { targetOutputStream -> |
| 59 | + inputStream?.copyTo(targetOutputStream) ?: logger.error { |
| 60 | + "Could not start a visualization because of missing resource html/$file" |
| 61 | + } |
| 62 | + } |
| 63 | + } |
58 | 64 | } |
59 | 65 | FileWriter(graphJs).use { |
60 | 66 | it.write( |
|
0 commit comments