Skip to content

Commit

Permalink
build: adds version catalogs to centralize versions (could be migrate…
Browse files Browse the repository at this point in the history
…d to .toml in the future)

Signed-off-by: Lorenzo Addazi <[email protected]>
  • Loading branch information
loradd committed Mar 11, 2024
1 parent d719d03 commit a22b785
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 110 deletions.
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
plugins {
id("net.researchgate.release") version "3.0.2"
alias(libs.plugins.release)
}

allprojects {
group = "com.strumenta.kolasu.languageserver"
}


release {
buildTasks.set(listOf(":kolasu-languageserver-library:publish", ":kolasu-languageserver-testing:publish", ":kolasu-languageserver-plugin:publishPlugins"))
git {
requireBranch.set("")
pushToRemote.set("origin")
}
}
}
24 changes: 7 additions & 17 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import java.net.URI

plugins {
id("org.jetbrains.kotlin.jvm") version "1.8.22"
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
id("maven-publish")
id("signing")
alias(libs.plugins.kotlin.jvm)
`maven-publish`
signing
}

repositories {
mavenCentral()
}

val kotlinVersion: String by project
val kolasuVersion: String by project
val lsp4jVersion: String by project
val luceneVersion: String by project

dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("com.strumenta.kolasu:kolasu-core:$kolasuVersion")
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:$lsp4jVersion")
implementation("org.apache.lucene:lucene-core:$luceneVersion")
implementation(libs.kotlin.reflect)
implementation(libs.kolasu.core)
implementation(libs.lsp4j)
implementation(libs.lucene)
}

java {
Expand Down Expand Up @@ -83,7 +77,3 @@ publishing {
signing {
sign(publishing.publications.getByName("language-server-library"))
}

ktlint {
version = "1.2.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ open class KolasuServer<T : Node>(
protected open val extensions: List<String> = listOf(),
protected open val enableDefinitionCapability: Boolean = false,
protected open val enableReferencesCapability: Boolean = false,
protected open val generator: CodeGenerator<T>? = null,
protected open val generator: CodeGenerator<T>? = null
) : LanguageServer, TextDocumentService, WorkspaceService, LanguageClientAware {
protected open lateinit var client: LanguageClient
protected open var configuration: JsonObject = JsonObject()
Expand All @@ -116,7 +116,7 @@ open class KolasuServer<T : Node>(

open fun startCommunication(
inputStream: InputStream = System.`in`,
outputStream: OutputStream = System.out,
outputStream: OutputStream = System.out
) {
val launcher = LSPLauncher.createServerLauncher(this, inputStream, outputStream)
connect(launcher.remoteProxy)
Expand All @@ -142,14 +142,14 @@ open class KolasuServer<T : Node>(
WorkspaceFoldersOptions().apply {
supported = true
changeNotifications = Either.forLeft("didChangeWorkspaceFoldersRegistration")
},
}
)

capabilities.setTextDocumentSync(
TextDocumentSyncOptions().apply {
openClose = true
change = TextDocumentSyncKind.Full
},
}
)
capabilities.setDocumentSymbolProvider(true)
capabilities.setDefinitionProvider(this.enableDefinitionCapability)
Expand All @@ -169,10 +169,10 @@ open class KolasuServer<T : Node>(
Registration(
"workspace/didChangeWatchedFiles",
"workspace/didChangeWatchedFiles",
DidChangeWatchedFilesRegistrationOptions(watchers),
),
),
),
DidChangeWatchedFilesRegistrationOptions(watchers)
)
)
)
)

client.registerCapability(
Expand All @@ -183,10 +183,10 @@ open class KolasuServer<T : Node>(
"workspace/didChangeConfiguration",
object {
val section = language
},
),
),
),
}
)
)
)
)
}

Expand All @@ -204,7 +204,7 @@ open class KolasuServer<T : Node>(

client.createProgress(WorkDoneProgressCreateParams(Either.forLeft("indexing")))
client.notifyProgress(
ProgressParams(Either.forLeft("indexing"), Either.forLeft(WorkDoneProgressBegin().apply { title = "indexing" })),
ProgressParams(Either.forLeft("indexing"), Either.forLeft(WorkDoneProgressBegin().apply { title = "indexing" }))
)
for (folder in folders) {
val projectFiles = File(URI(folder)).walk().filter { extensions.contains(it.extension) }.toList()
Expand All @@ -220,9 +220,9 @@ open class KolasuServer<T : Node>(
Either.forLeft(
WorkDoneProgressReport().apply {
this.percentage = percentage
},
),
),
}
)
)
)
}
}
Expand Down Expand Up @@ -257,7 +257,7 @@ open class KolasuServer<T : Node>(

open fun parse(
uri: String,
text: String,
text: String
) {
if (!::indexWriter.isInitialized) return

Expand Down Expand Up @@ -324,22 +324,22 @@ open class KolasuServer<T : Node>(
Diagnostic(
toLSPRange(node.position!!),
"Leaf type: ${node.simpleNodeType} but findByPositionType: ${tree.findByPosition(
node.position!!,
)?.simpleNodeType}",
node.position!!
)?.simpleNodeType}"
).apply {
severity = DiagnosticSeverity.Warning
},
}
)
}

if (showLeafPositions) {
diagnostics.add(
Diagnostic(
toLSPRange(node.position!!),
"Leaf position: ${node.position}, Source text: ${node.sourceText}",
"Leaf position: ${node.position}, Source text: ${node.sourceText}"
).apply {
severity = DiagnosticSeverity.Information
},
}
)
}
}
Expand Down Expand Up @@ -369,7 +369,7 @@ open class KolasuServer<T : Node>(

protected open fun appendNamedChildren(
node: Node,
parent: DocumentSymbol,
parent: DocumentSymbol
) {
var nextParent = parent
if (node is PossiblyNamed && node.name != null) {
Expand All @@ -392,15 +392,15 @@ open class KolasuServer<T : Node>(
}

override fun definition(
params: DefinitionParams?,
params: DefinitionParams?
): CompletableFuture<Either<MutableList<out Location>, MutableList<out LocationLink>>> {
val document = getDocument(params) ?: return CompletableFuture.completedFuture(null)

val symbolID = document.fields.find { it.name() == "reference" }?.stringValue() ?: return CompletableFuture.completedFuture(null)
val result =
indexSearcher.search(
TermQuery(Term("uuid", symbolID)),
1,
1
).scoreDocs.firstOrNull() ?: return CompletableFuture.completedFuture(null)
val definition = indexSearcher.storedFields().document(result.doc)

Expand All @@ -426,7 +426,7 @@ open class KolasuServer<T : Node>(
val result =
indexSearcher.search(
TermQuery(Term("uuid", symbolID)),
1,
1
).scoreDocs.firstOrNull() ?: return CompletableFuture.completedFuture(null)
val definition = indexSearcher.storedFields().document(result.doc)

Expand Down Expand Up @@ -469,7 +469,7 @@ open class KolasuServer<T : Node>(
val range =
Range(
Position(document.get("startLine").toInt() - 1, document.get("startColumn").toInt()),
Position(document.get("endLine").toInt() - 1, document.get("endColumn").toInt()),
Position(document.get("endLine").toInt() - 1, document.get("endColumn").toInt())
)
return Location(uri, range)
}
Expand Down Expand Up @@ -532,22 +532,22 @@ open class KolasuServer<T : Node>(

protected open fun log(
text: String,
verboseExplanation: String? = null,
verboseExplanation: String? = null
) {
client.logTrace(LogTraceParams(text, verboseExplanation))
}

protected open fun showNotification(
text: String,
messageType: MessageType = MessageType.Info,
messageType: MessageType = MessageType.Info
) {
client.showMessage(MessageParams(messageType, text))
}

protected open fun askClient(
messageText: String,
options: List<String> = listOf("Yes", "No"),
messageType: MessageType = MessageType.Info,
messageType: MessageType = MessageType.Info
): CompletableFuture<String> {
val future = CompletableFuture<String>()

Expand All @@ -572,13 +572,13 @@ open class KolasuServer<T : Node>(
interface CodeGenerator<T : Node> {
fun generate(
tree: T,
uri: String,
uri: String
)
}

interface SymbolResolver {
fun resolveSymbols(
tree: Node?,
uri: String,
uri: String
)
}
27 changes: 10 additions & 17 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("org.jetbrains.kotlin.jvm") version "1.8.22"
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
id("maven-publish")
id("java-gradle-plugin")
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ktlint)
`maven-publish`
`java-gradle-plugin`
id("com.gradle.plugin-publish") version "1.2.1"
id("com.github.gmazzo.buildconfig") version "5.3.5"
}
Expand All @@ -12,15 +12,9 @@ repositories {
gradlePluginPortal()
}

val kotlinVersion: String by project
val kolasuVersion: String by project
val luceneVersion: String by project
val lsp4jVersion: String by project
val junitVersion: String by project

dependencies {
implementation("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:7.1.2")
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:$kotlinVersion")
implementation(libs.shadow)
implementation(libs.kotlin.jvm)
}

gradlePlugin {
Expand All @@ -41,14 +35,13 @@ gradlePlugin {
buildConfig {
packageName = "com.strumenta.kolasu.languageserver.plugin"
buildConfigField("KOLASU_LSP_VERSION", "${project.version}")
buildConfigField("KOLASU_VERSION", kolasuVersion)
buildConfigField("LUCENE_VERSION", luceneVersion)
buildConfigField("LSP4J_VERSION", lsp4jVersion)
buildConfigField("JUNIT_VERSION", junitVersion)
buildConfigField("KOLASU_VERSION", libs.versions.kolasu)
buildConfigField("LUCENE_VERSION", libs.versions.lucene)
buildConfigField("LSP4J_VERSION", libs.versions.lsp4j)
buildConfigField("JUNIT_VERSION", libs.versions.junit5)
}

ktlint {
version = "1.2.1"
filter {
exclude { it.file.path.contains(layout.buildDirectory.dir("generated").get().toString()) }
}
Expand Down
Loading

0 comments on commit a22b785

Please sign in to comment.