diff --git a/library/src/main/kotlin/com/strumenta/kolasu/languageserver/KolasuServer.kt b/library/src/main/kotlin/com/strumenta/kolasu/languageserver/KolasuServer.kt index 1610c08..8aace06 100644 --- a/library/src/main/kotlin/com/strumenta/kolasu/languageserver/KolasuServer.kt +++ b/library/src/main/kotlin/com/strumenta/kolasu/languageserver/KolasuServer.kt @@ -95,7 +95,14 @@ import kotlin.reflect.jvm.javaField import kotlin.reflect.typeOf import kotlin.system.exitProcess -open class KolasuServer(protected open val parser: ASTParser?, protected open val language: String = "", protected open val extensions: List = listOf(), protected open val symbolResolver: SymbolResolver? = null, protected open val generator: CodeGenerator? = null) : LanguageServer, TextDocumentService, WorkspaceService, LanguageClientAware { +open class KolasuServer( + protected open val parser: ASTParser?, + protected open val language: String = "", + protected open val extensions: List = listOf(), + protected open val enableDefinitionCapability: Boolean = false, + protected open val enableReferencesCapability: Boolean = false, + protected open val generator: CodeGenerator? = null +) : LanguageServer, TextDocumentService, WorkspaceService, LanguageClientAware { protected open lateinit var client: LanguageClient protected open var configuration: JsonObject = JsonObject() @@ -134,11 +141,8 @@ open class KolasuServer(protected open val parser: ASTParser?, prot capabilities.setTextDocumentSync(TextDocumentSyncOptions().apply { openClose = true; change = TextDocumentSyncKind.Full }) capabilities.setDocumentSymbolProvider(true) - - if (symbolResolver != null) { - capabilities.setDefinitionProvider(true) - capabilities.setReferencesProvider(true) - } + capabilities.setDefinitionProvider(this.enableDefinitionCapability) + capabilities.setReferencesProvider(this.enableReferencesCapability) return CompletableFuture.completedFuture(InitializeResult(capabilities)) } @@ -211,7 +215,6 @@ open class KolasuServer(protected open val parser: ASTParser?, prot if (!::indexWriter.isInitialized) return val parsingResult = parser?.parse(text) ?: return - symbolResolver?.resolveSymbols(parsingResult.root, uri) files[uri] = parsingResult val tree = parsingResult.root ?: return diff --git a/testing/src/main/kotlin/testing/TestKolasuServer.kt b/testing/src/main/kotlin/testing/TestKolasuServer.kt index dad0591..409ede3 100644 --- a/testing/src/main/kotlin/testing/TestKolasuServer.kt +++ b/testing/src/main/kotlin/testing/TestKolasuServer.kt @@ -3,7 +3,6 @@ package testing import com.google.gson.JsonObject import com.strumenta.kolasu.languageserver.CodeGenerator import com.strumenta.kolasu.languageserver.KolasuServer -import com.strumenta.kolasu.languageserver.SymbolResolver import com.strumenta.kolasu.model.Node import com.strumenta.kolasu.parsing.ASTParser import org.eclipse.lsp4j.DefinitionParams @@ -33,7 +32,8 @@ import kotlin.system.measureNanoTime open class TestKolasuServer( protected open var parser: ASTParser? = null, - protected open var symbolResolver: SymbolResolver? = null, + protected open var enableDefinitionCapability: Boolean = false, + protected open var enableReferencesCapability: Boolean = false, protected open var codeGenerator: CodeGenerator? = null, protected open var language: String = "languageserver", protected open var fileExtensions: List = listOf(), @@ -48,7 +48,7 @@ open class TestKolasuServer( } protected open fun initializeServer() { - server = KolasuServer(parser, language, fileExtensions, symbolResolver, codeGenerator) + server = KolasuServer(parser, language, fileExtensions, enableDefinitionCapability, enableReferencesCapability, codeGenerator) expectDiagnostics(0) val workspace = workspacePath.toUri().toString()