From aabd1529d3edd1cadda40b9d9f78b5eb1e19b0c9 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Sun, 19 Jan 2025 11:53:53 +0900 Subject: [PATCH 1/5] feat: bump deps and add missed deps this will made save to cache won't error again --- gradle/libs.versions.toml | 10 ++++++++-- server/build.gradle.kts | 4 ++++ .../main/kotlin/org/javacs/kt/KotlinLanguageServer.kt | 7 ++----- .../src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt | 5 +++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 167e4e5e9..fb3d31e77 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] kotlinVersion = "2.1.0" lsp4jVersion = "0.21.2" -exposedVersion = "0.37.3" +exposedVersion = "0.58.0" jmhVersion = "1.37" guavaVersion = "33.4.0-jre" fernFlowerVersion = "243.22562.218" @@ -45,9 +45,15 @@ org-openjdk-jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh org-xerial-sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version = "3.48.0.0" } # buildSrc -org-jetbrains-kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin",version.ref = "kotlinVersion" } +org-jetbrains-kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" } + +# this is used to remove the error info in console log +org-slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } +org-slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } + [plugins] com-github-jk1-tcdeps = { id = "com.github.jk1.tcdeps", version = "1.6.2" } + com-jaredsburrows-license = { id = "com.jaredsburrows.license", version = "0.9.8" } io-gitlab-arturbosch-detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.22.0" } diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 915dcc767..3ed60ed33 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -40,6 +40,10 @@ dependencies { implementation(libs.org.eclipse.lsp4j.lsp4j) implementation(libs.org.eclipse.lsp4j.jsonrpc) + // used to clear the error during console log + implementation(libs.org.slf4j.api) + implementation(libs.org.slf4j.simple) + implementation(kotlin("compiler")) implementation(kotlin("scripting-compiler")) implementation(kotlin("scripting-jvm-host-unshaded")) diff --git a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt index e8da0ff99..4b8bca971 100644 --- a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt +++ b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt @@ -100,18 +100,15 @@ class KotlinLanguageServer( val clientCapabilities = params.capabilities config.completion.snippets.enabled = clientCapabilities?.textDocument?.completion?.completionItem?.snippetSupport ?: false - if (clientCapabilities?.window?.workDoneProgress ?: false) { + if (clientCapabilities?.window?.workDoneProgress == true) { progressFactory = LanguageClientProgress.Factory(client) } - if (clientCapabilities?.textDocument?.rename?.prepareSupport ?: false) { + if (clientCapabilities?.textDocument?.rename?.prepareSupport == true) { serverCapabilities.renameProvider = Either.forRight(RenameOptions(false)) } - @Suppress("DEPRECATION") val folders = params.workspaceFolders?.takeIf { it.isNotEmpty() } - ?: params.rootUri?.let(::WorkspaceFolder)?.let(::listOf) - ?: params.rootPath?.let(Paths::get)?.toUri()?.toString()?.let(::WorkspaceFolder)?.let(::listOf) ?: listOf() val progress = params.workDoneToken?.let { LanguageClientProgress("Workspace folders", it, client) } diff --git a/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt b/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt index 5fbb9b66b..f95798157 100644 --- a/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt +++ b/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt @@ -15,6 +15,7 @@ import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.* import kotlin.sequences.Sequence +import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq private const val MAX_FQNAME_LENGTH = 255 private const val MAX_SHORT_NAME_LENGTH = 80 @@ -110,7 +111,7 @@ class SymbolIndex( addDeclarations(allDescriptors(module, exclusions)) val finished = System.currentTimeMillis() - val count = Symbols.slice(Symbols.fqName.count()).selectAll().first()[Symbols.fqName.count()] + val count = Symbols.selectAll().first()[Symbols.fqName.count()] LOG.info("Updated full symbol index in ${finished - started} ms! (${count} symbol(s))") } } catch (e: Exception) { @@ -133,7 +134,7 @@ class SymbolIndex( addDeclarations(add) val finished = System.currentTimeMillis() - val count = Symbols.slice(Symbols.fqName.count()).selectAll().first()[Symbols.fqName.count()] + val count = Symbols.selectAll().first()[Symbols.fqName.count()] LOG.info("Updated symbol index in ${finished - started} ms! (${count} symbol(s))") } } catch (e: Exception) { From 72bd593c3ab89e2649b576eff75ec0057ca2f223 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Sun, 19 Jan 2025 11:58:07 +0900 Subject: [PATCH 2/5] chore: catch possible error during update database --- detekt.yml | 2 ++ gradle/libs.versions.toml | 1 + .../org/javacs/kt/classpath/CachedClassPathResolver.kt | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/detekt.yml b/detekt.yml index 37d53d3ad..3c478fcf8 100644 --- a/detekt.yml +++ b/detekt.yml @@ -24,6 +24,8 @@ exceptions: - NumberFormatException - ParseException - MissingPropertyException + TooGenericExceptionCaught: + active: false naming: excludes: *standardExcludes diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fb3d31e77..9831aa7ed 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,6 +3,7 @@ kotlinVersion = "2.1.0" lsp4jVersion = "0.21.2" exposedVersion = "0.58.0" jmhVersion = "1.37" +slf4j = "2.0.16" guavaVersion = "33.4.0-jre" fernFlowerVersion = "243.22562.218" diff --git a/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt b/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt index d81667deb..ca5383ded 100644 --- a/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt +++ b/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt @@ -116,7 +116,13 @@ internal class CachedClassPathResolver( LOG.info("Cached classpath is outdated or not found. Resolving again") val newClasspath = wrapped.classpath - updateClasspathCache(newClasspath, false) + // We need to make sure the cache resolve won't throw error here, make deps can be loaded successfully + try { + // in old exposed this will throw error, but I do not know if it will throw again, so I catch here + updateClasspathCache(newClasspath, false) + } catch (e: Exception) { + LOG.warn("Something error during update database, error: ${e.message}") + } return newClasspath } From ef18adf6c4feaa43ad9d06afcec48b25cd06aef2 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Tue, 21 Jan 2025 10:09:42 +0900 Subject: [PATCH 3/5] chore: code style modify as author suggested --- server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt | 4 ++-- .../kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt index 4b8bca971..62e04cadb 100644 --- a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt +++ b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt @@ -100,11 +100,11 @@ class KotlinLanguageServer( val clientCapabilities = params.capabilities config.completion.snippets.enabled = clientCapabilities?.textDocument?.completion?.completionItem?.snippetSupport ?: false - if (clientCapabilities?.window?.workDoneProgress == true) { + if (clientCapabilities?.window?.workDoneProgress ?: false) { progressFactory = LanguageClientProgress.Factory(client) } - if (clientCapabilities?.textDocument?.rename?.prepareSupport == true) { + if (clientCapabilities?.textDocument?.rename?.prepareSupport ?: false) { serverCapabilities.renameProvider = Either.forRight(RenameOptions(false)) } diff --git a/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt b/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt index ca5383ded..8e0d2b842 100644 --- a/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt +++ b/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt @@ -121,7 +121,7 @@ internal class CachedClassPathResolver( // in old exposed this will throw error, but I do not know if it will throw again, so I catch here updateClasspathCache(newClasspath, false) } catch (e: Exception) { - LOG.warn("Something error during update database, error: ${e.message}") + LOG.warn("Error during database update, error: ${e.message}") } return newClasspath From cba8c5815ee2de0482cee622d3c4f6e5e48a02bc Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Tue, 21 Jan 2025 11:05:05 +0900 Subject: [PATCH 4/5] chore: bump lsp4Version --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9831aa7ed..00dcf651a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] kotlinVersion = "2.1.0" -lsp4jVersion = "0.21.2" +lsp4jVersion = "0.23.1" exposedVersion = "0.58.0" jmhVersion = "1.37" slf4j = "2.0.16" From b4555b335118bb7efbb1438fefb7266e752d5e0c Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Sat, 8 Feb 2025 21:36:03 +0900 Subject: [PATCH 5/5] fix: remove depecated function in exposed --- server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt | 8 ++++---- .../org/javacs/kt/classpath/CachedClassPathResolver.kt | 2 +- .../main/kotlin/org/javacs/kt/database/DatabaseService.kt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt b/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt index f95798157..777fbd690 100644 --- a/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt +++ b/server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt @@ -93,7 +93,7 @@ class SymbolIndex( init { transaction(db) { - SchemaUtils.createMissingTablesAndColumns(Symbols, Locations, Ranges, Positions) + SchemaUtils.create(Symbols, Locations, Ranges, Positions) } } @@ -111,7 +111,7 @@ class SymbolIndex( addDeclarations(allDescriptors(module, exclusions)) val finished = System.currentTimeMillis() - val count = Symbols.selectAll().first()[Symbols.fqName.count()] + val count = Symbols.select(Symbols.fqName.count()).first()[Symbols.fqName.count()] LOG.info("Updated full symbol index in ${finished - started} ms! (${count} symbol(s))") } } catch (e: Exception) { @@ -134,7 +134,7 @@ class SymbolIndex( addDeclarations(add) val finished = System.currentTimeMillis() - val count = Symbols.selectAll().first()[Symbols.fqName.count()] + val count = Symbols.select(Symbols.fqName.count()).first()[Symbols.fqName.count()] LOG.info("Updated symbol index in ${finished - started} ms! (${count} symbol(s))") } } catch (e: Exception) { @@ -149,7 +149,7 @@ class SymbolIndex( if (validFqName(descriptorFqn) && (extensionReceiverFqn?.let { validFqName(it) } != false)) { Symbols.deleteWhere { - (Symbols.fqName eq descriptorFqn.toString()) and (Symbols.extensionReceiverType eq extensionReceiverFqn?.toString()) + (fqName eq descriptorFqn.toString()) and (extensionReceiverType eq extensionReceiverFqn?.toString()) } } else { LOG.warn("Excluding symbol {} from index since its name is too long", descriptorFqn.toString()) diff --git a/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt b/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt index 8e0d2b842..c160d29a5 100644 --- a/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt +++ b/shared/src/main/kotlin/org/javacs/kt/classpath/CachedClassPathResolver.kt @@ -101,7 +101,7 @@ internal class CachedClassPathResolver( init { transaction(db) { - SchemaUtils.createMissingTablesAndColumns( + SchemaUtils.create( ClassPathMetadataCache, ClassPathCacheEntry, BuildScriptClassPathCacheEntry ) } diff --git a/shared/src/main/kotlin/org/javacs/kt/database/DatabaseService.kt b/shared/src/main/kotlin/org/javacs/kt/database/DatabaseService.kt index 0f80f73b4..b8e53b60d 100644 --- a/shared/src/main/kotlin/org/javacs/kt/database/DatabaseService.kt +++ b/shared/src/main/kotlin/org/javacs/kt/database/DatabaseService.kt @@ -37,7 +37,7 @@ class DatabaseService { db = getDbFromFile(storagePath) val currentVersion = transaction(db) { - SchemaUtils.createMissingTablesAndColumns(DatabaseMetadata) + SchemaUtils.create(DatabaseMetadata) DatabaseMetadataEntity.all().firstOrNull()?.version ?: 0 }