Skip to content

Commit

Permalink
Bump the gradle group with 2 updates (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Oct 6, 2024
1 parent 9d67432 commit be9d2b5
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ class ClassMappingRequestBuilder(private val constructor: IrConstructor, private
return if (mappers.size == 1) {
PropertyMappingViaMapperTransformation(mappers.single(), null)
} else if (mappers.size > 1) {
val location = when (source) {
is ExplicitClassMappingSource -> location(context.function!!.fileEntry, source.origin)
else -> location(context.function!!)
}
val error = Problem.error(
"Multiple mappers resolved to be used in an implicit via",
location(context.function!!),
location,
listOf(
"Call one of ${mappers.joinToString { it.clazz.name.asString() }} explicitly.",
"Delete all except one of ${mappers.joinToString { it.clazz.name.asString() }}.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.mappie.resolving.classes.sources

import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
Expand Down Expand Up @@ -32,7 +33,9 @@ sealed interface ClassMappingSource {
}

sealed interface ImplicitClassMappingSource : ClassMappingSource
sealed interface ExplicitClassMappingSource : ClassMappingSource
sealed interface ExplicitClassMappingSource : ClassMappingSource {
val origin: IrElement
}

data class ParameterDefaultValueMappingSource(
val parameter: IrValueParameter,
Expand Down Expand Up @@ -62,14 +65,17 @@ data class ExplicitPropertyMappingSource(
val transformation : PropertyMappingTransformation?,
) : ExplicitClassMappingSource {
override val type = type(reference.getter!!.owner.returnType, transformation)
override val origin = reference
}

data class ValueMappingSource(val expression: IrExpression) : ExplicitClassMappingSource {
override val type = expression.type
override val origin = expression
}

data class ExpressionMappingSource(val expression: IrExpression) : ExplicitClassMappingSource {
override val type = (expression.type as IrSimpleType).arguments[1].typeOrFail
override val origin = expression
}

sealed interface PropertyMappingTransformation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface MappingValidation {
addAll(MultipleSourcesProblems.of(mapping).all())
addAll(UnsafeTypeAssignmentProblems.of(context, mapping).all())
addAll(UnsafePlatformTypeAssignmentProblems.of(context, mapping).all())
addAll(UnknownParameterNameProblems.of(mapping).all())
addAll(UnknownParameterNameProblems.of(context, mapping).all())
addAll(VisibilityProblems.of(context, mapping).all())
addAll(MapperGenerationRequestProblems.of(context, mapping).all())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
package tech.mappie.validation.problems.classes

import org.jetbrains.kotlin.ir.util.fileEntry
import org.jetbrains.kotlin.name.Name
import tech.mappie.resolving.ClassMappingRequest
import tech.mappie.resolving.classes.sources.ClassMappingSource
import tech.mappie.resolving.classes.sources.ExplicitClassMappingSource
import tech.mappie.util.location
import tech.mappie.validation.Problem
import tech.mappie.validation.ValidationContext

class UnknownParameterNameProblems(private val unknowns: Set<Name>) {
class UnknownParameterNameProblems(
private val context: ValidationContext,
private val unknowns: Map<Name, List<ClassMappingSource>>,
) {

fun all(): List<Problem> = unknowns.map {
Problem.error("Identifier ${it.asString()} does not occur as as setter or as a parameter in constructor")
fun all(): List<Problem> = unknowns.map { (name, sources) ->
Problem.error(
"Identifier ${name.asString()} does not occur as as setter or as a parameter in constructor",
when (val source = sources.firstOrNull()) {
is ExplicitClassMappingSource -> location(context.function.fileEntry, source.origin)
else -> location(context.function)
}
)
}

companion object {
fun of(mapping: ClassMappingRequest): UnknownParameterNameProblems =
UnknownParameterNameProblems(mapping.unknowns.keys)
fun of(context: ValidationContext, mapping: ClassMappingRequest): UnknownParameterNameProblems =
UnknownParameterNameProblems(context, mapping.unknowns)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class CompilationAssertionDsl(private val result: KotlinCompilation.Result) {

fun hasErrorMessage(line: Int, message: String, suggestions: List<String> = emptyList()) {
assertThat(result.messages).containsPattern(
Pattern.compile("e: file://.+${line}.+ ${escape(messageOf(message, suggestions))}")
Pattern.compile("e: file://.+\\.kt:${line}.+ ${escape(messageOf(message, suggestions))}")
)
}

fun hasWarningMessage(line: Int, message: String) {
assertThat(result.messages).containsPattern(
Pattern.compile("w: file://.+${line}:.+${escape(message)}")
Pattern.compile("w: file://.+\\.kt:${line}:.+${escape(message)}")
)
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ kotlin = "2.0.20"
kotlin-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" }
kotlin-gradle-plugin-api = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlin" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version = "5.11.1" }
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.176" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version = "5.11.2" }
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.177" }
okio = { module = "com.squareup.okio:okio", version = "3.9.1" }
assertj-core = { module = "org.assertj:assertj-core", version = "3.26.3" }

Expand Down

0 comments on commit be9d2b5

Please sign in to comment.