Skip to content

Commit

Permalink
configure tester class through constructor instead of overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Azpillaga Aldalur committed Oct 27, 2023
1 parent 5924033 commit 9a709f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ import org.junit.jupiter.api.BeforeEach
import java.nio.file.Path
import java.nio.file.Paths

open class TestKolasuServer<T : Node>() {

protected open var parser: ASTParser<T>? = null
protected open var symbolResolver: SymbolResolver? = null
protected open var generator: CodeGenerator<T>? = null

protected open var language: String = "languageserver"
protected open var fileExtensions: List<String> = listOf()

protected open var workspacePath: Path = Paths.get("src", "test", "resources")
open class TestKolasuServer<T : Node>(
protected open var parser: ASTParser<T>? = null,
protected open var symbolResolver: SymbolResolver? = null,
protected open var codeGenerator: CodeGenerator<T>? = null,
protected open var language: String = "languageserver",
protected open var fileExtensions: List<String> = listOf(),
protected open var workspacePath: Path = Paths.get("src", "test", "resources")
) {

protected open lateinit var server: KolasuServer<T>

Expand All @@ -46,7 +44,7 @@ open class TestKolasuServer<T : Node>() {
}

protected open fun initializeServer(): KolasuServer<T> {
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)) })
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,13 +11,10 @@ import java.nio.file.Files
import java.nio.file.Paths
import kotlin.io.path.toPath

class TestRPGKolasuServer : TestKolasuServer<CompilationUnit>() {

override var parser: ASTParser<CompilationUnit>? = RPGKolasuParser()
override var symbolResolver: SymbolResolver? = RPGSymbolResolverAdapter()
class TestRPGKolasuServer : TestKolasuServer<CompilationUnit>(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)
Expand Down

0 comments on commit 9a709f9

Please sign in to comment.