Skip to content

update dependencies, expecially for exposed and lsp #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ exceptions:
- NumberFormatException
- ParseException
- MissingPropertyException
TooGenericExceptionCaught:
active: false

naming:
excludes: *standardExcludes
Expand Down
13 changes: 10 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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" }
4 changes: 4 additions & 0 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
3 changes: 0 additions & 3 deletions server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
9 changes: 5 additions & 4 deletions server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,7 +93,7 @@ class SymbolIndex(

init {
transaction(db) {
SchemaUtils.createMissingTablesAndColumns(Symbols, Locations, Ranges, Positions)
SchemaUtils.create(Symbols, Locations, Ranges, Positions)
}
}

Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal class CachedClassPathResolver(

init {
transaction(db) {
SchemaUtils.createMissingTablesAndColumns(
SchemaUtils.create(
ClassPathMetadataCache, ClassPathCacheEntry, BuildScriptClassPathCacheEntry
)
}
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DatabaseService {
db = getDbFromFile(storagePath)

val currentVersion = transaction(db) {
SchemaUtils.createMissingTablesAndColumns(DatabaseMetadata)
SchemaUtils.create(DatabaseMetadata)

DatabaseMetadataEntity.all().firstOrNull()?.version ?: 0
}
Expand Down