Skip to content

Commit 210c9d1

Browse files
committed
tempDir is just Path
1 parent a841752 commit 210c9d1

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

src/main/scala/org/polystat/cli/Java.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ object Java:
8989
cfg: ProcessedConfig,
9090
): IO[Unit] =
9191
for
92-
tmp <- cfg.tempDir
9392
_ <- cfg.input match // writing EO files to tempDir
9493
case Input.FromStdin =>
9594
for
@@ -102,24 +101,24 @@ object Java:
102101
j2eoVersion,
103102
j2eo,
104103
inputDir = stdinTmp,
105-
outputDir = tmp,
104+
outputDir = cfg.tempDir,
106105
)
107106
yield ()
108107
case Input.FromFile(path) =>
109-
runJ2EO(j2eoVersion, j2eo, inputDir = path, outputDir = tmp)
108+
runJ2EO(j2eoVersion, j2eo, inputDir = path, outputDir = cfg.tempDir)
110109
case Input.FromDirectory(path) =>
111-
runJ2EO(j2eoVersion, j2eo, inputDir = path, outputDir = tmp)
110+
runJ2EO(j2eoVersion, j2eo, inputDir = path, outputDir = cfg.tempDir)
112111
// J2EO deletes the tmp directory when there are no files to analyze
113112
// This causes the subsequent call to EO.analyze to fail, because there is no temp directory.
114113
// The line below patches this issue by creating the temp directory if it was deleted by J2EO.
115114
_ <- Files[IO]
116-
.exists(tmp)
115+
.exists(cfg.tempDir)
117116
.ifM(
118117
ifTrue = IO.unit,
119-
ifFalse = Files[IO].createDirectory(tmp),
118+
ifFalse = Files[IO].createDirectory(cfg.tempDir),
120119
)
121120
_ <- EO.analyze(
122-
cfg.copy(input = Input.FromDirectory(tmp))
121+
cfg.copy(input = Input.FromDirectory(cfg.tempDir))
123122
)
124123
yield ()
125124

src/main/scala/org/polystat/cli/Main.scala

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,25 @@ object Main extends IOApp:
6969
lang,
7070
AnalyzerConfig(inex, input, tmp, fmts, out),
7171
) =>
72-
val processedConfig = ProcessedConfig(
73-
filteredAnalyzers = filterAnalyzers(inex),
74-
tempDir = tmp match
72+
for
73+
tempDir <- tmp match
7574
case Some(path) =>
7675
IO.println(s"Cleaning ${path.absolute}...") *> path.clean
7776
case None => Files[IO].createTempDirectory
78-
,
79-
output = out,
80-
input = input,
81-
fmts = fmts,
82-
)
83-
val analysisResults: IO[Unit] =
84-
lang match
85-
case SupportedLanguage.EO => EO.analyze(processedConfig)
86-
case SupportedLanguage.Java(j2eo, j2eoVersion) =>
87-
Java.analyze(j2eoVersion, j2eo, processedConfig)
88-
case SupportedLanguage.Python => Python.analyze(processedConfig)
89-
analysisResults
77+
processedConfig = ProcessedConfig(
78+
filteredAnalyzers = filterAnalyzers(inex),
79+
tempDir = tempDir,
80+
output = out,
81+
input = input,
82+
fmts = fmts,
83+
)
84+
analysisResults: IO[Unit] =
85+
lang match
86+
case SupportedLanguage.EO => EO.analyze(processedConfig)
87+
case SupportedLanguage.Java(j2eo, j2eoVersion) =>
88+
Java.analyze(j2eoVersion, j2eo, processedConfig)
89+
case SupportedLanguage.Python => Python.analyze(processedConfig)
90+
yield ()
9091
end execute
9192

9293
end Main

src/main/scala/org/polystat/cli/PolystatConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object PolystatConfig:
2020

2121
final case class ProcessedConfig(
2222
filteredAnalyzers: List[ASTAnalyzer[IO]],
23-
tempDir: IO[Path],
23+
tempDir: Path,
2424
input: Input,
2525
fmts: List[OutputFormat],
2626
output: Output,

src/main/scala/org/polystat/cli/Python.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ object Python:
1212

1313
def analyze(cfg: ProcessedConfig): IO[Unit] =
1414
for
15-
tmp <- cfg.tempDir
1615
_ <- readCodeFromInput(".py", cfg.input)
1716
.evalMap { case (path, code) =>
1817
val fileName = path.fileName.toString
@@ -22,14 +21,14 @@ object Python:
2221
)
2322
_ <- maybeCode match
2423
case Some(code) =>
25-
writeOutputTo(tmp / path.replaceExt(".eo"))(code)
24+
writeOutputTo(cfg.tempDir / path.replaceExt(".eo"))(code)
2625
case None => IO.println(s"Couldn't analyze $path...")
2726
yield ()
2827
end for
2928
}
3029
.compile
3130
.drain
32-
_ <- EO.analyze(cfg.copy(input = Input.FromDirectory(tmp)))
31+
_ <- EO.analyze(cfg.copy(input = Input.FromDirectory(cfg.tempDir)))
3332
yield ()
3433

3534
end Python

0 commit comments

Comments
 (0)