From 9a709f9de13b5693c5041e5163bf01e63f99cc26 Mon Sep 17 00:00:00 2001 From: Martin Azpillaga Aldalur Date: Fri, 27 Oct 2023 14:06:45 +0200 Subject: [PATCH] configure tester class through constructor instead of overrides --- .../testing/TestKolasuServer.kt | 20 +++++++++---------- .../testing/rpg/TestRPGKolasuServer.kt | 9 ++------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/library/src/test/kotlin/com/strumenta/languageserver/testing/TestKolasuServer.kt b/library/src/test/kotlin/com/strumenta/languageserver/testing/TestKolasuServer.kt index be660a1..743b7e6 100644 --- a/library/src/test/kotlin/com/strumenta/languageserver/testing/TestKolasuServer.kt +++ b/library/src/test/kotlin/com/strumenta/languageserver/testing/TestKolasuServer.kt @@ -27,16 +27,14 @@ import org.junit.jupiter.api.BeforeEach import java.nio.file.Path import java.nio.file.Paths -open class TestKolasuServer() { - - protected open var parser: ASTParser? = null - protected open var symbolResolver: SymbolResolver? = null - protected open var generator: CodeGenerator? = null - - protected open var language: String = "languageserver" - protected open var fileExtensions: List = listOf() - - protected open var workspacePath: Path = Paths.get("src", "test", "resources") +open class TestKolasuServer( + protected open var parser: ASTParser? = null, + protected open var symbolResolver: SymbolResolver? = null, + protected open var codeGenerator: CodeGenerator? = null, + protected open var language: String = "languageserver", + protected open var fileExtensions: List = listOf(), + protected open var workspacePath: Path = Paths.get("src", "test", "resources") +) { protected open lateinit var server: KolasuServer @@ -46,7 +44,7 @@ open class TestKolasuServer() { } protected open fun initializeServer(): KolasuServer { - val server = KolasuServer(parser, language, fileExtensions, symbolResolver, generator) + val server = KolasuServer(parser, language, fileExtensions, symbolResolver, codeGenerator) server.connect(DiagnosticSizeCheckerClient(0)) val workspace = workspacePath.toUri().toString() server.initialize(InitializeParams().apply { workspaceFolders = mutableListOf(WorkspaceFolder(workspace)) }) diff --git a/library/src/test/kotlin/com/strumenta/languageserver/testing/rpg/TestRPGKolasuServer.kt b/library/src/test/kotlin/com/strumenta/languageserver/testing/rpg/TestRPGKolasuServer.kt index c39925a..720bad0 100644 --- a/library/src/test/kotlin/com/strumenta/languageserver/testing/rpg/TestRPGKolasuServer.kt +++ b/library/src/test/kotlin/com/strumenta/languageserver/testing/rpg/TestRPGKolasuServer.kt @@ -1,7 +1,5 @@ package com.strumenta.languageserver.testing.rpg -import com.strumenta.kolasu.parsing.ASTParser -import com.strumenta.languageserver.SymbolResolver import com.strumenta.languageserver.testing.TestKolasuServer import com.strumenta.rpgparser.RPGKolasuParser import com.strumenta.rpgparser.model.CompilationUnit @@ -13,13 +11,10 @@ import java.nio.file.Files import java.nio.file.Paths import kotlin.io.path.toPath -class TestRPGKolasuServer : TestKolasuServer() { - - override var parser: ASTParser? = RPGKolasuParser() - override var symbolResolver: SymbolResolver? = RPGSymbolResolverAdapter() +class TestRPGKolasuServer : TestKolasuServer(RPGKolasuParser(), RPGSymbolResolverAdapter()) { private val fibonacciFile = Paths.get("src", "test", "resources", "fibonacci.rpgle").toUri().toString() - private val inexistentFile = Paths.get("inexistent").toUri().toString() + private val inexistentFile = "inexistentFile" private val symbolPosition = Position(19, 38) private val noSymbolPosition = Position(14, 1) private val externalSymbolPosition = Position(40, 52)