Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
8488842
feat: first basic dsl
MarcoFratta Sep 3, 2025
725e116
feat: add deployments dsl
MarcoFratta Sep 4, 2025
cfa4c7f
refactor: handle generic types
MarcoFratta Sep 4, 2025
a09052c
feat: add contents handling
MarcoFratta Sep 5, 2025
e20e2b2
feat: handle linking rule
MarcoFratta Sep 5, 2025
dc58811
chore: change error message
MarcoFratta Sep 5, 2025
ff2019d
test: improve testing
MarcoFratta Sep 5, 2025
658e527
feat!: add support for actions and conditions
MarcoFratta Sep 10, 2025
3fa5ab5
test: add tests for new features
MarcoFratta Sep 10, 2025
ce0a83a
feat: add support for terminators
MarcoFratta Sep 10, 2025
73f8ade
refactor: simplify dsl syntax
MarcoFratta Sep 11, 2025
4a3fe19
feat: add support for output monitors
MarcoFratta Sep 11, 2025
4fd2023
feat: add support for layers
MarcoFratta Sep 11, 2025
99c66b3
feat: improve test framework
MarcoFratta Oct 15, 2025
2c2e61b
feat: add support for exporters and global reactions
MarcoFratta Oct 15, 2025
0cc43a9
feat: add support for variables using delegates
MarcoFratta Oct 15, 2025
728c00d
fix: fix seeds problem
MarcoFratta Oct 27, 2025
45af007
refactor: refactor dsl structure
MarcoFratta Oct 27, 2025
3377814
feat: add support for custom nodes definition
MarcoFratta Oct 28, 2025
1a00e1b
feat: add support for node properties
MarcoFratta Oct 28, 2025
3632937
refactor: add code initial documentation
MarcoFratta Nov 8, 2025
58075d0
refactor: move yml test files
MarcoFratta Nov 8, 2025
05388de
refactor: add doc and better testing
MarcoFratta Nov 8, 2025
b0c0279
feat!: add support for alchemist.kts file loading
MarcoFratta Nov 8, 2025
10197cf
feat!: add support for alchemist.kts file loading
MarcoFratta Nov 8, 2025
eab8346
test: test .alchemist.kts file loading
MarcoFratta Nov 8, 2025
0ac359f
refactor: add external imports config file
MarcoFratta Nov 8, 2025
93e7191
feat!: add ksp function helpers generator
MarcoFratta Nov 8, 2025
4feae4c
feat!: add ksp function helpers generator
MarcoFratta Nov 8, 2025
0af86c8
feat: add @BuildDsl to some classes
MarcoFratta Nov 8, 2025
4afa89a
refactor: better code organization
MarcoFratta Nov 10, 2025
d794bf8
test: add performance tests
MarcoFratta Nov 10, 2025
7de533b
feat: add support for batch runs
MarcoFratta Nov 16, 2025
b604010
feat: add custom scope definition for @BuildDsl annotation
MarcoFratta Nov 16, 2025
8439b64
test: add test simulation config
MarcoFratta Nov 16, 2025
e4be08e
chore: sync repo fork
MarcoFratta Nov 16, 2025
19cf438
Merge remote-tracking branch 'upstream/master'
MarcoFratta Nov 16, 2025
f9043ca
Merge branch 'master' into master
MarcoFratta Nov 25, 2025
66a245c
fix: remove vcs.xml changes
MarcoFratta Nov 25, 2025
e15e314
fix: remove useless file
MarcoFratta Nov 25, 2025
209b760
fix: remove .gitignore duplicated folder
MarcoFratta Nov 25, 2025
ef11fad
style: improve formatting
MarcoFratta Nov 25, 2025
2207683
refactor: refactor build.gradle.kts dependency
MarcoFratta Nov 25, 2025
417dc6a
feat: add multiplatform support
MarcoFratta Nov 25, 2025
65f756f
chore: remove useless comment
MarcoFratta Nov 25, 2025
fc36e72
feat: change alchemist script definition
MarcoFratta Nov 26, 2025
985a729
chore: add dependencies versions
MarcoFratta Nov 26, 2025
29ef41e
fix: fix processor tests
MarcoFratta Nov 26, 2025
63b8124
chore: remove println
MarcoFratta Nov 26, 2025
20da4d7
style: remove redundant parenthesis
MarcoFratta Nov 26, 2025
fac688c
style: remove redundant parenthesis
MarcoFratta Nov 26, 2025
c46b844
chore: remove not needed compiler arg
MarcoFratta Nov 26, 2025
bc0ca1c
Merge branch 'master' into master
MarcoFratta Nov 26, 2025
1f809f0
Merge branch 'master' into master
DanySK Nov 26, 2025
bd82f9f
Merge branch 'master' into master
MarcoFratta Nov 26, 2025
9830c28
feat: remove CommitMessageInspectionProfile from vcs.xml
MarcoFratta Nov 26, 2025
420e2a2
fix: fix cpd errors
MarcoFratta Nov 26, 2025
3cbeef6
fix: fix cpd errors in alchemist-loading
MarcoFratta Nov 26, 2025
4abc0a8
fix: rename sources dir names
MarcoFratta Nov 26, 2025
5a8a67c
style: fix vertical spacing inconsistencies
MarcoFratta Nov 26, 2025
f3ff0ec
style: fix vertical spacing inconsistencies
MarcoFratta Nov 26, 2025
2441330
refactor: simplify expression
MarcoFratta Nov 26, 2025
4e5ec58
refactor: simplify expressions
MarcoFratta Nov 26, 2025
45c929b
chore: add empty line at the end
MarcoFratta Nov 26, 2025
9b5f96a
refactor: change annotation from @BuildDsl to @AlchemistKotlinDSL
MarcoFratta Nov 26, 2025
3661269
docs: add missing documentation
MarcoFratta Nov 26, 2025
7e62d79
style: fix detekt errors
MarcoFratta Nov 27, 2025
751172a
style: fix detekt errors
MarcoFratta Nov 27, 2025
3351ab4
Merge branch 'master' into master
MarcoFratta Nov 28, 2025
7ed5e23
refactor: replace exporters function signature
MarcoFratta Nov 28, 2025
49a2306
refactor: better performance test
MarcoFratta Nov 28, 2025
674f211
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
2215f61
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
b6a2d28
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
caff28f
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
7ec3895
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
a89e9ff
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
4052d6f
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
4128c8e
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
bbedd33
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
f4f2b60
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
9ac4062
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
6c1fd15
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
98d5ed1
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
84a35af
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
5e8dded
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
8df2401
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
8a2f3bf
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
f2a4f3b
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
93936d3
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
c07c910
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
4f5d195
Merge branch 'master' into master
DanySK Dec 1, 2025
1c6f04b
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
f24e3dd
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
cdd5144
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
1ed4f35
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
fae4a11
chore(build): update the javadoc.io cache
DanySK Dec 1, 2025
6edb8ac
chore(deps): update react to v2025.12.0-19.2.0 (minor) (#5004)
renovate[bot] Dec 1, 2025
f312b55
Merge branch 'master' into master
DanySK Dec 2, 2025
577b5fc
Merge branch 'master' into master
DanySK Dec 13, 2025
7682742
Merge branch 'master' into master
DanySK Dec 13, 2025
474d9f0
style(dsl-processor): cleanup `ConstructorFinder`
DanySK Dec 15, 2025
5670a7f
build: remove duplicate `-Xcontext-parameters` argument in compiler o…
DanySK Dec 15, 2025
a1e5383
chore: add copyright notice to BoundProcessor.kt
DanySK Dec 15, 2025
0c32587
refactor: simplify type argument formatting in BoundProcessor.kt
DanySK Dec 15, 2025
a991691
chore: remove unnecessary blank line in build.gradle.kts
DanySK Dec 15, 2025
70629ad
chore: remove unused jvm() configuration and test dependencies in bui…
DanySK Dec 15, 2025
fbe7bda
refactor: streamline logging in DslBuilderProcessor.kt
DanySK Dec 15, 2025
4ca02f4
Merge branch 'master' into master
DanySK Dec 15, 2025
d0f788c
style: use orEmpty()
DanySK Dec 15, 2025
127731c
chore: track the dokka caches
DanySK Dec 15, 2025
5a0c4f6
fix: split support types to separate files
DanySK Dec 15, 2025
a2caf85
refactor: move InjectionType to a separate data package
DanySK Dec 15, 2025
1d5977c
refactor: improve logging and structure in DslBuilderProcessor
DanySK Dec 15, 2025
ca3c1aa
refactor: refactor the Kotlin DSL generator
DanySK Dec 18, 2025
414fec4
refactor: enhance context handling in DslBuilderProcessor and Paramet…
DanySK Dec 18, 2025
5ab4dba
refactor: extract ContextType enum to a new file for better organization
DanySK Dec 18, 2025
73be28b
refactor: simplify type checks in ParameterInjector by using isSubtypeOf
DanySK Dec 18, 2025
b2782c2
refactor: simplify manual scope check in ParameterInjector
DanySK Dec 18, 2025
2c69253
refactor: make ProcessorConfig internal and remove unused type consta…
DanySK Dec 18, 2025
9d7e889
refactor: remove redundant logging of found symbols in DslBuilderProc…
DanySK Dec 18, 2025
609179d
refactor: simplify AlchemistKotlinDSL annotation and remove unused pa…
DanySK Dec 18, 2025
e4f8700
marmellata
DanySK Dec 19, 2025
b494dec
marmellata
DanySK Dec 22, 2025
d5d3a6c
feat!: rewrite the code generator
DanySK Dec 23, 2025
136808a
refactor: suppress Detekt false positives for undocumented public fun…
DanySK Dec 23, 2025
0f3745b
refactor: streamline DslBuilderProcessor by removing unused imports a…
DanySK Dec 23, 2025
68cd5c0
feat: enhance simulation context to include RandomGenerator in DSL fu…
DanySK Dec 23, 2025
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ scala_compiler.xml
# Exceptions
# Keep 'build' packages in src directories
!**/src/**/build/
!**/src/**/build/**
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion alchemist-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies {
api(libs.jool)
api(libs.listset)
implementation(libs.kotlin.reflect)

testImplementation(libs.kotlin.test)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2010-2025, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/

package it.unibo.alchemist.boundary.dsl

/**
* Annotation used to mark classes that should have DSL builder functions generated.
* When applied to a class, the DSL processor will generate a builder function
* that can be used in Alchemist DSL scripts to create instances of the annotated class.
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class AlchemistKotlinDSL
16 changes: 16 additions & 0 deletions alchemist-dsl-processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Libs.alchemist

plugins {
id("kotlin-multiplatform-convention")
}

kotlin {
sourceSets {
val jvmMain by getting {
dependencies {
api(alchemist("api"))
implementation(libs.ksp.api)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
package it.unibo.alchemist.boundary.dsl.processor

import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.getConstructors
import com.google.devtools.ksp.isPublic
import com.google.devtools.ksp.processing.CodeGenerator
import com.google.devtools.ksp.processing.Dependencies
import com.google.devtools.ksp.processing.KSPLogger
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.processing.SymbolProcessor
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.google.devtools.ksp.symbol.KSType
import com.google.devtools.ksp.validate
import it.unibo.alchemist.boundary.dsl.AlchemistKotlinDSL
import it.unibo.alchemist.boundary.dsl.processor.data.InjectableConstructor
import it.unibo.alchemist.boundary.dsl.processor.extensions.asString
import it.unibo.alchemist.boundary.dsl.processor.extensions.nameOrTypeName
import it.unibo.alchemist.boundary.dsl.processor.extensions.typeName
import it.unibo.alchemist.core.Simulation
import it.unibo.alchemist.model.Environment
import it.unibo.alchemist.model.Incarnation
import it.unibo.alchemist.model.LinkingRule
import it.unibo.alchemist.model.Node
import it.unibo.alchemist.model.Reaction
import it.unibo.alchemist.model.TimeDistribution
import java.io.PrintWriter
import java.nio.charset.StandardCharsets
import org.apache.commons.math3.random.RandomGenerator

/** Symbol processor that emits DSL helpers for `@AlchemistKotlinDSL` classes. */
class DslBuilderProcessor(private val codeGenerator: CodeGenerator, private val logger: KSPLogger) : SymbolProcessor {

/**
* Processes every `@AlchemistKotlinDSL` symbol,
* generating helpers and returning unresolved ones.
*/
override fun process(resolver: Resolver): List<KSAnnotated> {
context(resolver) {
logger.dslInfo("Starting processing")
val annotationName = AlchemistKotlinDSL::class.qualifiedName
check(!annotationName.isNullOrBlank()) {
"The Alchemist Kotlin DSL annotation name is invalid or missing: '$annotationName'"
}
logger.dslInfo("Alchemist DSL annotation: $annotationName")
return resolver.getSymbolsWithAnnotation(annotationName)
.fold(emptyList()) { invalidElements, symbol ->
when {
!symbol.validate() -> invalidElements + symbol
else -> {
if (symbol is KSClassDeclaration) {
processClass(symbol)
}
invalidElements
}
}
}
}
}

context(resolver: Resolver)
private fun processClass(classDeclaration: KSClassDeclaration) {
logger.dslInfo("Processing class ${classDeclaration.simpleName.asString()}")
logger.dslInfo("Class qualified name: ${classDeclaration.qualifiedName?.asString()}")
val file = codeGenerator.createNewFile(
dependencies = classDeclaration.containingFile
?.let { Dependencies(false, it) }
?: Dependencies.ALL_FILES,
packageName = classDeclaration.packageName.asString(),
fileName = "${classDeclaration.simpleName.asString()}Factory.kt",
)
val writer = PrintWriter(file, true, StandardCharsets.UTF_8)
writer.println("// This file is generated by Alchemist DSL Processor. Do not edit manually.")
writer.println()
writer.println("package ${classDeclaration.packageName.asString()}")
writer.println()
val functionName = classDeclaration.simpleName.asString().replaceFirstChar { it.lowercaseChar() }
val injectableConstructors = classDeclaration.getConstructors()
.filter { it.isPublic() }
.mapNotNull { InjectableConstructor(it) }
.toList()
if (injectableConstructors.isEmpty()) {
logger.warn(
"No injectable constructors, ${AlchemistKotlinDSL::class.qualifiedName} will have no effect.",
classDeclaration,
)
}
injectableConstructors.forEach { (constructor, injectableParams, preservedParams) ->
val context = injectableParams.joinToString(prefix = "context(", postfix = ")") { param ->
"${param.nameOrTypeName()}: ${param.type.asString()}"
}
writer.println(context)
val typeParameters = constructor.typeParameters.takeIf { it.isNotEmpty() }
?.joinToString(prefix = "<", postfix = "> ") { typeArgument ->
buildString {
if (typeArgument.isReified) {
append("reified ")
}
append(typeArgument.name.asString())
}
}
.orEmpty()
val parameters = preservedParams.joinToString(separator = NEWLINE_INDENT) { parameter ->
buildString {
if (parameter.isCrossInline) {
append("crossinline ")
}
if (parameter.isNoInline) {
append("noinline ")
}
if (parameter.isVararg) {
append("vararg ")
}
append(
"${parameter.name?.asString()}: ${parameter.type.asString()}",
)
}
}
val whereClause = constructor.typeParameters
.flatMap { typeParam ->
typeParam.bounds.map { bound ->
"${typeParam.simpleName.asString()} : ${bound.asString()}"
}
}
.takeIf { it.isNotEmpty() }
?.joinToString(separator = NEWLINE_INDENT, prefix = "where\n ", postfix = "\n")
.orEmpty()
val arguments = constructor.parameters.joinToString(NEWLINE_INDENT) {
buildString {
if (it.isVararg) {
append("*")
}
append(it.nameOrTypeName())
}
}
writer.println(
"""
|fun $typeParameters$functionName(
| $parameters
|) $whereClause= ${classDeclaration.typeName}(
| $arguments
|)
""".trimMargin(),
)
}
}

internal companion object {

const val NEWLINE_INDENT = ",\n| "

private fun KSPLogger.dslInfo(message: String) = info("${DslBuilderProcessor::class.simpleName}: $message")

context(resolver: Resolver)
fun injectableTypes(): Set<KSType> = sequenceOf(
resolver.getClassDeclarationByName<Environment<*, *>>(),
resolver.getClassDeclarationByName<Incarnation<*, *>>(),
resolver.getClassDeclarationByName<LinkingRule<*, *>>(),
resolver.getClassDeclarationByName<Node<*>>(),
resolver.getClassDeclarationByName<RandomGenerator>(),
resolver.getClassDeclarationByName<Reaction<*>>(),
resolver.getClassDeclarationByName<Simulation<*, *>>(),
resolver.getClassDeclarationByName<TimeDistribution<*>>(),
).map { checkNotNull(it).asStarProjectedType() }.toSet()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package it.unibo.alchemist.boundary.dsl.processor

import com.google.devtools.ksp.processing.SymbolProcessor
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
import com.google.devtools.ksp.processing.SymbolProcessorProvider

/**
* Provider for [DslBuilderProcessor] that creates instances for KSP processing.
*/
class DslBuilderProcessorProvider : SymbolProcessorProvider {
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor =
DslBuilderProcessor(environment.codeGenerator, environment.logger)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2010-2025, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/

package it.unibo.alchemist.boundary.dsl.processor.data

import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.KSFunctionDeclaration
import com.google.devtools.ksp.symbol.KSValueParameter
import it.unibo.alchemist.boundary.dsl.processor.extensions.isInjectable

internal data class InjectableConstructor(
val constructor: KSFunctionDeclaration,
val injectableParameters: List<KSValueParameter>,
val preservedParameters: List<KSValueParameter>,
) {
companion object {
context(resolver: Resolver)
operator fun invoke(constructor: KSFunctionDeclaration): InjectableConstructor? {
val (injectable, preserved) = constructor.parameters.partition { it.type.resolve().isInjectable() }
return when {
injectable.isNotEmpty() && injectable.toSet().size == injectable.size && injectable.none {
it.isVararg
} ->
InjectableConstructor(constructor, injectable, preserved)
else -> null
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (C) 2010-2025, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/

package it.unibo.alchemist.boundary.dsl.processor.extensions

import com.google.devtools.ksp.symbol.KSDeclaration

internal val KSDeclaration.typeName: String
get() = qualifiedName?.asString()?.takeIf { it.isNotEmpty() } ?: simpleName.asString()
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2010-2025, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/
import com.google.devtools.ksp.symbol.KSFunctionDeclaration
import com.google.devtools.ksp.symbol.KSType
import com.google.devtools.ksp.symbol.KSValueParameter

/**
* Finds a public constructor for the given class declaration.
* Prefers the primary constructor, otherwise returns the constructor
* with the most parameters.
*
* @return The found constructor, or null if no suitable constructor exists
*/
internal val KSFunctionDeclaration.parameterTypes: List<KSType> get() = parameters.map { it.type.resolve() }
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (C) 2010-2025, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/

package it.unibo.alchemist.boundary.dsl.processor.extensions

import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.KSType
import it.unibo.alchemist.boundary.dsl.processor.DslBuilderProcessor

context(resolver: Resolver)
internal fun KSType.isInjectable() = DslBuilderProcessor.injectableTypes().any { it.isAssignableFrom(this) }
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2010-2025, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/

package it.unibo.alchemist.boundary.dsl.processor.extensions

import com.google.devtools.ksp.symbol.KSTypeParameter
import com.google.devtools.ksp.symbol.KSTypeReference

internal fun KSTypeReference.asString(): String = buildString {
val type = resolve()
when (val declaration = type.declaration) {
is KSTypeParameter -> append(declaration.simpleName.asString())
else -> append(declaration.typeName)
}
if (type.arguments.isNotEmpty()) {
append(
type.arguments.joinToString(prefix = "<", postfix = ">") {
it.type?.asString() ?: "*"
},
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (C) 2010-2025, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/

package it.unibo.alchemist.boundary.dsl.processor.extensions

import com.google.devtools.ksp.symbol.KSValueParameter

internal fun KSValueParameter.nameOrTypeName(): String = name?.asString()
?: type.resolve().declaration.simpleName.asString().replaceFirstChar { it.lowercase() }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it.unibo.alchemist.boundary.dsl.processor.DslBuilderProcessorProvider
2 changes: 1 addition & 1 deletion alchemist-full/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ val packageTasks = validFormats.filterIsInstance<ValidPackaging>().map { packagi
tasks.assemble.configure { dependsOn(packageTasks) }

tasks.withType<AbstractArchiveTask> {
duplicatesStrategy = DuplicatesStrategy.WARN
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

publishing.publications {
Expand Down
Loading
Loading