From aa360aa27a4ab833c4a8330549b246026945f7ef Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Thu, 20 Jun 2024 11:38:08 +0200 Subject: [PATCH] small adjustments --- .../{H2Connection.scala => H2ConnectionProvider.scala} | 8 ++++---- .../scala/meta/internal/metals/SqlSharedIndices.scala | 7 ++++--- .../main/scala/scala/meta/internal/metals/Tables.scala | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) rename metals/src/main/scala/scala/meta/internal/metals/{H2Connection.scala => H2ConnectionProvider.scala} (97%) diff --git a/metals/src/main/scala/scala/meta/internal/metals/H2Connection.scala b/metals/src/main/scala/scala/meta/internal/metals/H2ConnectionProvider.scala similarity index 97% rename from metals/src/main/scala/scala/meta/internal/metals/H2Connection.scala rename to metals/src/main/scala/scala/meta/internal/metals/H2ConnectionProvider.scala index 7dec51837d9..669f104d25b 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/H2Connection.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/H2ConnectionProvider.scala @@ -22,7 +22,7 @@ import org.h2.mvstore.MVStoreException import org.h2.tools.Upgrade abstract class H2ConnectionProvider( - directory: () => AbsolutePath, + directory: => AbsolutePath, name: String, migrations: String, ) extends Cancelable { @@ -33,7 +33,7 @@ abstract class H2ConnectionProvider( protected def connection: Connection = connect() - protected def optDirectory: Option[AbsolutePath] = Try(directory()).toOption + protected def optDirectory: Option[AbsolutePath] = Try(directory).toOption protected def databasePath: Option[AbsolutePath] = optDirectory.map(_.resolve("metals.h2.db")) @@ -92,9 +92,9 @@ abstract class H2ConnectionProvider( val autoServer = if (isAutoServer) ";AUTO_SERVER=TRUE" else "" - val dbfile = directory().resolve("metals") + val dbfile = directory.resolve("metals") // from "h2" % "2.0.206" the only option is the MVStore, which uses `metals.mv.db` file - val oldDbfile = directory().resolve("metals.h2.db") + val oldDbfile = directory.resolve("metals.h2.db") if (oldDbfile.exists) { scribe.info(s"Deleting old database format $oldDbfile") oldDbfile.delete() diff --git a/metals/src/main/scala/scala/meta/internal/metals/SqlSharedIndices.scala b/metals/src/main/scala/scala/meta/internal/metals/SqlSharedIndices.scala index 0fae605226d..1a642a590a1 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/SqlSharedIndices.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/SqlSharedIndices.scala @@ -6,9 +6,10 @@ import scala.meta.io.AbsolutePath class SqlSharedIndices extends H2ConnectionProvider( - () => AbsolutePath(Paths.get(sys.props("user.home"))).resolve(".metals"), - "metals-shared", - "/shared-db/migration", + directory = + AbsolutePath(Paths.get(sys.props("user.home"))).resolve(".metals"), + name = "metals-shared", + migrations = "/shared-db/migration", ) { val jvmTypeHierarchy: JarTypeHierarchy = new JarTypeHierarchy(() => connect) diff --git a/metals/src/main/scala/scala/meta/internal/metals/Tables.scala b/metals/src/main/scala/scala/meta/internal/metals/Tables.scala index 4c609887d62..7f3d7969ad8 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Tables.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Tables.scala @@ -11,9 +11,9 @@ final class Tables( workspace: AbsolutePath, time: Time, ) extends H2ConnectionProvider( - () => workspace.resolve(".metals"), - "metals", - "/db/migration", + directory = workspace.resolve(".metals"), + name = "metals", + migrations = "/db/migration", ) { val jarSymbols = new JarTopLevels(() => connection)