Skip to content

Commit

Permalink
Merge branch 'unstable' into shon/fix-config-tilde-expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
Shon Feder authored Jan 13, 2022
2 parents 1a14c44 + b5634d6 commit 1f54624
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
35 changes: 12 additions & 23 deletions mod-tool/src/main/scala/at/forsyte/apalache/tla/Tool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ object Tool extends LazyLogging {
try {
cmd match {
case parse: ParseCmd =>
val injector = injectorFactory(parse)
handleExceptions[ParseCmd](injector, runParse(injector, _), parse)
val injector = Guice.createInjector(new ParserModule)
handleExceptions(runParse, injector, parse)

case check: CheckCmd =>
val injector = injectorFactory(check)
handleExceptions[CheckCmd](injector, runCheck(injector, _), check)
val injector = Guice.createInjector(new CheckerModule)
handleExceptions(runCheck, injector, check)

case test: TestCmd =>
val injector = injectorFactory(test)
handleExceptions[TestCmd](injector, runTest(injector, _), test)
val injector = Guice.createInjector(new CheckerModule)
handleExceptions(runTest, injector, test)

case typecheck: TypeCheckCmd =>
val injector = injectorFactory(typecheck)
handleExceptions[TypeCheckCmd](injector, runTypeCheck(injector, _), typecheck)
val injector = Guice.createInjector(new TypeCheckerModule)
handleExceptions(runTypeCheck, injector, typecheck)

case server: ServerCmd =>
val injector = injectorFactory(server)
handleExceptions[ServerCmd](injector, runServer(injector, _), server)
val injector = Guice.createInjector(new CheckerModule)
handleExceptions(runServer, injector, server)

case config: ConfigCmd =>
configure(config)
Expand Down Expand Up @@ -354,21 +354,10 @@ object Tool extends LazyLogging {
props ++ hereProps
}

private def injectorFactory(cmd: Command): Injector = {
cmd match {
case _: ParseCmd => Guice.createInjector(new ParserModule)
case _: CheckCmd => Guice.createInjector(new CheckerModule)
case _: TestCmd => Guice.createInjector(new CheckerModule)
case _: TypeCheckCmd => Guice.createInjector(new TypeCheckerModule)
case _: ServerCmd => Guice.createInjector(new CheckerModule)
case _ => throw new RuntimeException("Unexpected command: " + cmd)
}
}

private def handleExceptions[C <: General](injector: Injector, fun: C => Int, cmd: C): Int = {
private def handleExceptions[C <: General](runner: (=> Injector, C) => Int, injector: Injector, cmd: C): Int = {
val adapter = injector.getInstance(classOf[ExceptionAdapter])
try {
fun(cmd)
runner(injector, cmd)
} catch {
case e: Exception if adapter.toMessage.isDefinedAt(e) =>
adapter.toMessage(e) match {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.9.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
2 changes: 1 addition & 1 deletion tlair/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<executions>
<execution>
<goals>
Expand Down

0 comments on commit 1f54624

Please sign in to comment.