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 167e4e5e9..00dcf651a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,9 @@ [versions] kotlinVersion = "2.1.0" -lsp4jVersion = "0.21.2" -exposedVersion = "0.37.3" +lsp4jVersion = "0.23.1" +exposedVersion = "0.58.0" jmhVersion = "1.37" +slf4j = "2.0.16" guavaVersion = "33.4.0-jre" fernFlowerVersion = "243.22562.218" @@ -45,9 +46,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..62e04cadb 100644 --- a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt +++ b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt @@ -108,10 +108,7 @@ class KotlinLanguageServer( 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..777fbd690 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 @@ -92,7 +93,7 @@ class SymbolIndex( init { transaction(db) { - SchemaUtils.createMissingTablesAndColumns(Symbols, Locations, Ranges, Positions) + SchemaUtils.create(Symbols, Locations, Ranges, Positions) } } @@ -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.select(Symbols.fqName.count()).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.select(Symbols.fqName.count()).first()[Symbols.fqName.count()] LOG.info("Updated symbol index in ${finished - started} ms! (${count} symbol(s))") } } catch (e: Exception) { @@ -148,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 d81667deb..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 ) } @@ -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("Error during database update, error: ${e.message}") + } return newClasspath } 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 }