Skip to content

Commit b9da2b2

Browse files
Merge pull request #131 from SpineEventEngine/update-deps
2 parents b3e6bc9 + 265c507 commit b9da2b2

File tree

14 files changed

+76
-147
lines changed

14 files changed

+76
-147
lines changed

buildSrc/src/main/kotlin/io/spine/internal/dependency/ProtoData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object ProtoData {
6565
* The version of ProtoData dependencies.
6666
*/
6767
val version: String
68-
private const val fallbackVersion = "0.51.0"
68+
private const val fallbackVersion = "0.54.2"
6969

7070
/**
7171
* The distinct version of ProtoData used by other build tools.
@@ -74,7 +74,7 @@ object ProtoData {
7474
* transitional dependencies, this is the version used to build the project itself.
7575
*/
7676
val dogfoodingVersion: String
77-
private const val fallbackDfVersion = "0.51.0"
77+
private const val fallbackDfVersion = "0.54.2"
7878

7979
/**
8080
* The artifact for the ProtoData Gradle plugin.

buildSrc/src/main/kotlin/io/spine/internal/dependency/Spine.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ object Spine {
4545
*
4646
* @see <a href="https://github.com/SpineEventEngine/base">spine-base</a>
4747
*/
48-
const val base = "2.0.0-SNAPSHOT.203"
48+
const val base = "2.0.0-SNAPSHOT.205"
4949

5050
/**
5151
* The version of [Spine.reflect].
@@ -89,7 +89,7 @@ object Spine {
8989
*
9090
* @see <a href="https://github.com/SpineEventEngine/mc-java">spine-mc-java</a>
9191
*/
92-
const val mcJava = "2.0.0-SNAPSHOT.213"
92+
const val mcJava = "2.0.0-SNAPSHOT.217"
9393

9494
/**
9595
* The version of [Spine.baseTypes].
@@ -124,7 +124,7 @@ object Spine {
124124
*
125125
* @see <a href="https://github.com/SpineEventEngine/tool-base">spine-tool-base</a>
126126
*/
127-
const val toolBase = "2.0.0-SNAPSHOT.218"
127+
const val toolBase = "2.0.0-SNAPSHOT.223"
128128

129129
/**
130130
* The version of [Spine.javadocTools].

dependencies.md

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

java/src/main/kotlin/io/spine/validation/java/DistributingGenerator.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2023, TeamDev. All rights reserved.
2+
* Copyright 2024, TeamDev. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Redistribution and use in source and/or binary forms, with or without
1111
* modification, must retain the above copyright notice and the following
@@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList
3030
import com.google.common.reflect.TypeToken
3131
import com.squareup.javapoet.CodeBlock
3232
import io.spine.protodata.Field
33+
import io.spine.protodata.messageOrEnumName
3334
import io.spine.protodata.backend.SecureRandomString
3435
import io.spine.protodata.java.ClassOrEnumName
3536
import io.spine.protodata.java.Expression
@@ -51,12 +52,12 @@ import kotlin.io.encoding.ExperimentalEncodingApi
5152
* A code generator that distributes the associated simple validation rule to elements of
5253
* a repeated field.
5354
*
54-
* A rule applied to a repeated fields, i.e., a list or a map, may be applied to the fields as
55+
* A rule applied to repeated fields, i.e., a list or a map, may be applied to the fields as
5556
* a whole, or to individual elements of the field.
5657
*
5758
* In the first case, no extra modifications to code generation are required.
5859
*
59-
* In the second case, this generator creates code that iterated over
60+
* In the second case, this generator creates the code that iterates over
6061
* the elements and applies the validation rule to them.
6162
*/
6263
internal class DistributingGenerator(

java/src/main/kotlin/io/spine/validation/java/ImplementValidatingBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ private fun PsiJavaFile.locateBuilderClass(messageClass: ClassName): PsiClass {
115115
*/
116116
private fun PsiClass.implementValidatingBuilder(messageClass: ClassName) {
117117
val superInterface = elementFactory.createClassReference(
118-
this,
119118
ValidatingBuilder::class.java.reference,
120-
messageClass.simpleName
119+
messageClass.simpleName,
120+
context = this,
121121
)
122122
implement(superInterface)
123123
}

java/src/main/kotlin/io/spine/validation/java/TypeExts.kt

Lines changed: 0 additions & 44 deletions
This file was deleted.

java/src/main/kotlin/io/spine/validation/java/ValidateGenerator.kt

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2023, TeamDev. All rights reserved.
2+
* Copyright 2024, TeamDev. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Redistribution and use in source and/or binary forms, with or without
1111
* modification, must retain the above copyright notice and the following
@@ -28,7 +28,7 @@ package io.spine.validation.java
2828

2929
import com.squareup.javapoet.CodeBlock
3030
import io.spine.protodata.Field
31-
import io.spine.protodata.Type
31+
import io.spine.protodata.isAny
3232
import io.spine.protodata.java.Expression
3333
import io.spine.protodata.java.Literal
3434
import io.spine.protodata.java.MessageReference
@@ -166,22 +166,3 @@ internal class ValidateGenerator(ctx: GenerationContext) : SimpleRuleGenerator(c
166166
return error().createParentViolation(ctx, violations)
167167
}
168168
}
169-
170-
/**
171-
* Tells if this type is `google.protobuf.Any`.
172-
*
173-
* TODO: Migrate to the similar property from ProtoData.
174-
*/
175-
private val Type.isAny: Boolean
176-
get() = (hasMessage()
177-
&& message.packageName.equals("google.protobuf"))
178-
&& message.simpleName.equals("Any")
179-
180-
181-
/**
182-
* Obtains the name of the field which includes a qualified name of the type which declares it.
183-
*
184-
* TODO: Migrate to an extension `val` from ProtoData.
185-
*/
186-
private val Field.qualifiedName: String
187-
get() = "${declaringType.qualifiedName}.${name.value}"

java/src/main/proto/spine/validation/java/type.proto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2023, TeamDev. All rights reserved.
2+
* Copyright 2024, TeamDev. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Redistribution and use in source and/or binary forms, with or without
1111
* modification, must retain the above copyright notice and the following
@@ -37,6 +37,7 @@ option java_multiple_files = true;
3737
option (internal_all) = true;
3838

3939
import "spine/protodata/ast.proto";
40+
import "spine/protodata/source.proto";
4041

4142
// A tuple of a message type and the header of the file where it is declared.
4243
message MessageWithFile {

model/src/main/java/io/spine/validation/ValidationPolicy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Redistribution and use in source and/or binary forms, with or without
1111
* modification, must retain the above copyright notice and the following
@@ -66,6 +66,7 @@ public abstract class ValidationPolicy<E extends EventMessage>
6666
* </pre>
6767
*/
6868
protected final EitherOf2<RuleAdded, Nothing> noReaction() {
69+
//TODO:2024-08-11:alexander.yevsyukov: Use EventProducer.noReaction() extension from `core-java`.
6970
return EitherOf2.withB(nothing());
7071
}
7172
}

model/src/main/kotlin/io/spine/validation/RequiredIdOptionPolicy.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Redistribution and use in source and/or binary forms, with or without
1111
* modification, must retain the above copyright notice and the following
@@ -23,10 +23,12 @@
2323
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
26+
2627
package io.spine.validation
2728

2829
import io.spine.core.External
2930
import io.spine.protodata.MessageType
31+
import io.spine.protodata.firstField
3032
import io.spine.protodata.event.TypeDiscovered
3133
import io.spine.server.event.React
3234
import io.spine.server.model.NoReaction
@@ -61,7 +63,7 @@ internal class RequiredIdOptionPolicy : RequiredIdPolicy() {
6163
if (!type.isEntityState()) {
6264
return noReaction()
6365
}
64-
val field = type.firstField()
66+
val field = type.firstField
6567
return withField(field)
6668
}
6769

model/src/main/kotlin/io/spine/validation/RequiredIdPatternPolicy.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Redistribution and use in source and/or binary forms, with or without
1111
* modification, must retain the above copyright notice and the following
@@ -23,12 +23,14 @@
2323
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
26+
2627
package io.spine.validation
2728

2829
import io.spine.core.External
2930
import io.spine.protodata.File
3031
import io.spine.protodata.FilePattern
3132
import io.spine.protodata.event.TypeDiscovered
33+
import io.spine.protodata.firstField
3234
import io.spine.protodata.matches
3335
import io.spine.server.event.React
3436
import io.spine.server.model.NoReaction
@@ -64,7 +66,7 @@ internal class RequiredIdPatternPolicy : RequiredIdPolicy() {
6466
return noReaction()
6567
}
6668
val type = event.type
67-
val field = type.firstField()
69+
val field = type.firstField
6870
return withField(field)
6971
}
7072

model/src/main/kotlin/io/spine/validation/RequiredIdPolicy.kt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Redistribution and use in source and/or binary forms, with or without
1111
* modification, must retain the above copyright notice and the following
@@ -26,9 +26,7 @@
2626
package io.spine.validation
2727

2828
import io.spine.protodata.Field
29-
import io.spine.protodata.MessageType
3029
import io.spine.protodata.event.TypeDiscovered
31-
import io.spine.protodata.qualifiedName
3230
import io.spine.protodata.settings.loadSettings
3331
import io.spine.server.model.NoReaction
3432
import io.spine.server.tuple.EitherOf2
@@ -61,8 +59,7 @@ internal abstract class RequiredIdPolicy : ValidationPolicy<TypeDiscovered>() {
6159
*
6260
* If the field is marked with `(required) = false`, no rule is generated.
6361
*
64-
* @param field
65-
* the ID field.
62+
* @param field ID field.
6663
* @return a required rule event or `NoReaction`, if the ID field is not required.
6764
*/
6865
@Suppress("ReturnCount") // prefer sooner exit and precise conditions.
@@ -77,16 +74,4 @@ internal abstract class RequiredIdPolicy : ValidationPolicy<TypeDiscovered>() {
7774
}
7875
return EitherOf2.withA(rule.get().toEvent(field.declaringType))
7976
}
80-
81-
/**
82-
* Obtains the first field declared in the type.
83-
*
84-
* The index of the field is not taken into account.
85-
*/
86-
protected fun MessageType.firstField(): Field {
87-
check(fieldCount != 0) {
88-
"The type `${name.qualifiedName}` must have at least one field."
89-
}
90-
return getField(0)
91-
}
9277
}

0 commit comments

Comments
 (0)