From 6fde93dff320d02993e9a208cc4f43b0044b79bd Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Fri, 14 Feb 2025 16:52:50 +0100 Subject: [PATCH 01/10] Make `FieldDeclaration` to be `open` instead of `sealed` --- java/src/main/kotlin/io/spine/protodata/java/Fields.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/java/src/main/kotlin/io/spine/protodata/java/Fields.kt b/java/src/main/kotlin/io/spine/protodata/java/Fields.kt index 36c6f6f43..4f536a40f 100644 --- a/java/src/main/kotlin/io/spine/protodata/java/Fields.kt +++ b/java/src/main/kotlin/io/spine/protodata/java/Fields.kt @@ -35,8 +35,15 @@ import io.spine.tools.psi.java.Environment.elementFactory * * The declared field may OR may not be initialized, * depending on a specific implementation. + * + * Note: the class is intentionally not `sealed`, allowing instantiation + * with arbitrary [code]. While not recommended for general use, this can + * be helpful, e.g., when converting JavaPoet or PSI fields to [FieldDeclaration]. + * + * @see InitField + * @see DeclField */ -public sealed class FieldDeclaration( +public open class FieldDeclaration( public val name: String, code: String ) : MemberDeclaration(code) { From 628a8d4edd30f310b11a328e8104eee780a7f4cd Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Fri, 14 Feb 2025 17:08:52 +0100 Subject: [PATCH 02/10] Add `compilationError()` extension that accept a lambda message --- .../io/spine/protodata/CompilationErrors.kt | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt diff --git a/api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt b/api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt new file mode 100644 index 000000000..ab3cd46de --- /dev/null +++ b/api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2025, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.protodata + +import io.spine.environment.Tests +import io.spine.protodata.Compilation.ERROR_EXIT_CODE +import io.spine.protodata.ast.File +import io.spine.protodata.ast.Span +import io.spine.protodata.ast.toPath + +/** + * Prints the error diagnostics to [System.err] and terminates the compilation. + * + * The termination of the compilation in the production mode is done by + * exiting the process with [ERROR_EXIT_CODE]. + * + * If the code is run [under tests][Tests] the method throws [Compilation.Error]. + * + * @param file The file in which the error occurred. + * @param span The location span of the erroneous Protobuf declaration. + * @param message The description of what went wrong. + * + * @throws Compilation.Error exception when called under tests. + */ +public fun compilationError(file: File, span: Span, message: () -> String): Nothing = + Compilation.error( + file.toPath().toFile(), + span.startLine, span.startColumn, + message() + ) From d251b09ea696f80a5ba73c1bfae07af93815609d Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Fri, 14 Feb 2025 17:47:13 +0100 Subject: [PATCH 03/10] Take the latest `core-java` --- buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt index 01dad3221..c58e68f97 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt @@ -34,7 +34,7 @@ package io.spine.dependency.local @Suppress("ConstPropertyName", "unused") object CoreJava { const val group = Spine.group - const val version = "2.0.0-SNAPSHOT.201" + const val version = "2.0.0-SNAPSHOT.202" const val coreArtifact = "spine-core" const val clientArtifact = "spine-client" From b6ef1d1cbe3171c2521d645c36425950dad644a1 Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Fri, 14 Feb 2025 17:47:31 +0100 Subject: [PATCH 04/10] Bump ProtoData -> `0.91.7` --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index a86dbf31f..01807c2f6 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -32,4 +32,4 @@ * * For dependencies on Spine SDK module please see [io.spine.dependency.local.Spine]. */ -val protoDataVersion: String by extra("0.91.6") +val protoDataVersion: String by extra("0.91.7") From 5ef79d59a4939c34128266a087179bfa9db2408e Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Fri, 14 Feb 2025 18:00:34 +0100 Subject: [PATCH 05/10] Update reports --- dependencies.md | 44 ++++++++++++++++++++++---------------------- pom.xml | 16 ++++++++-------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dependencies.md b/dependencies.md index fcba7b931..1cf490105 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.protodata:protodata-api:0.91.6` +# Dependencies of `io.spine.protodata:protodata-api:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -1041,12 +1041,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:13 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:10 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-api-tests:0.91.6` +# Dependencies of `io.spine.protodata:protodata-api-tests:0.91.7` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 13.0. @@ -1894,12 +1894,12 @@ This report was generated on **Thu Feb 13 18:05:13 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:13 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:10 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-backend:0.91.6` +# Dependencies of `io.spine.protodata:protodata-backend:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -2928,12 +2928,12 @@ This report was generated on **Thu Feb 13 18:05:13 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:13 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:11 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-cli:0.91.6` +# Dependencies of `io.spine.protodata:protodata-cli:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -4045,12 +4045,12 @@ This report was generated on **Thu Feb 13 18:05:13 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:14 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:12 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-gradle-api:0.91.6` +# Dependencies of `io.spine.protodata:protodata-gradle-api:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -5061,12 +5061,12 @@ This report was generated on **Thu Feb 13 18:05:14 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:14 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:12 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-gradle-plugin:0.91.6` +# Dependencies of `io.spine.protodata:protodata-gradle-plugin:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -6249,12 +6249,12 @@ This report was generated on **Thu Feb 13 18:05:14 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-java:0.91.6` +# Dependencies of `io.spine.protodata:protodata-java:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -7283,12 +7283,12 @@ This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-params:0.91.6` +# Dependencies of `io.spine.protodata:protodata-params:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -8324,12 +8324,12 @@ This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-protoc:0.91.6` +# Dependencies of `io.spine.protodata:protodata-protoc:0.91.7` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -9166,12 +9166,12 @@ This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-test-env:0.91.6` +# Dependencies of `io.spine.protodata:protodata-test-env:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -10215,12 +10215,12 @@ This report was generated on **Thu Feb 13 18:05:15 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:16 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Feb 14 17:57:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-testlib:0.91.6` +# Dependencies of `io.spine.protodata:protodata-testlib:0.91.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -11351,4 +11351,4 @@ This report was generated on **Thu Feb 13 18:05:16 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 13 18:05:16 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Fri Feb 14 17:57:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/pom.xml b/pom.xml index c9a7acf57..6bc47aff8 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.protodata ProtoData -0.91.6 +0.91.7 2015 @@ -110,7 +110,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-server - 2.0.0-SNAPSHOT.201 + 2.0.0-SNAPSHOT.202 compile @@ -131,6 +131,12 @@ all modules and does not describe the project structure per-subproject. 2.0.0-SNAPSHOT.244 compile + + io.spine.tools + spine-testutil-server + 2.0.0-SNAPSHOT.202 + compile + io.spine.tools spine-tool-base @@ -209,12 +215,6 @@ all modules and does not describe the project structure per-subproject. 2.0.0-SNAPSHOT.244 test - - io.spine.tools - spine-testutil-server - 2.0.0-SNAPSHOT.201 - test - io.spine.tools spine-time-testlib From d5362fd8b75dd902e9912897f45a035f6ea2c4b3 Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Mon, 17 Feb 2025 12:40:27 +0100 Subject: [PATCH 06/10] Merge `FieldDeclaration` into a single class --- .../kotlin/io/spine/protodata/java/Fields.kt | 121 ++++++------------ 1 file changed, 39 insertions(+), 82 deletions(-) diff --git a/java/src/main/kotlin/io/spine/protodata/java/Fields.kt b/java/src/main/kotlin/io/spine/protodata/java/Fields.kt index 4f536a40f..ead0ad9f2 100644 --- a/java/src/main/kotlin/io/spine/protodata/java/Fields.kt +++ b/java/src/main/kotlin/io/spine/protodata/java/Fields.kt @@ -33,100 +33,57 @@ import io.spine.tools.psi.java.Environment.elementFactory /** * A declaration of a Java field. * - * The declared field may OR may not be initialized, - * depending on a specific implementation. - * - * Note: the class is intentionally not `sealed`, allowing instantiation - * with arbitrary [code]. While not recommended for general use, this can - * be helpful, e.g., when converting JavaPoet or PSI fields to [FieldDeclaration]. - * - * @see InitField - * @see DeclField + * The declared field may OR may not be initialized. */ -public open class FieldDeclaration( +public class FieldDeclaration( public val name: String, code: String ) : MemberDeclaration(code) { /** - * Returns an expression that reads the value of this field. + * Declares an initialized Java field. + * + * An example usage: + * + * ``` + * val height = FieldDeclaration("public final", PrimitiveName.INT, "height", Expression("180")) + * println(height) // `public final int height = 180;` + * ``` + * + * @param modifiers The field modifiers separated with a space. + * @param type The field type. + * @param name The field name. + * @param value The field value. */ - public fun read(useThis: Boolean = false): ReadField = ReadField(name, useThis) -} - -/** - * Declares and initializes a Java field. - * - * An example usage: - * - * ``` - * val height = InitField("public final", PrimitiveName.INT, "height", Expression("180")) - * println(height) // `public final int height = 180;` - * ``` - * - * @param modifiers The field modifiers separated with a space. - * @param type The field type. - * @param name The field name. - * @param value The field value. - */ -public class InitField( - public val modifiers: String, - public val type: JavaTypeName, - name: String, - public val value: Expression -) : FieldDeclaration(name, "$modifiers $type $name = $value;") - -/** - * Declares a Java field with the given parameters. - * - * Please note, the declared field is NOT initialized. - * - * An example usage: - * - * ``` - * val height = DeclField("public final", PrimitiveName.INT, "height") - * println(height) // `public final int height;` - * ``` - * - * @param modifiers The field modifiers separated with a space. - * @param type The field type. - * @param name The field name. - */ -public class DeclField( - public val modifiers: String, - public val type: JavaTypeName, - name: String -) : FieldDeclaration(name, "$modifiers $type $name;") { + public constructor( + modifiers: String, + type: JavaTypeName, + name: String, + value: Expression + ) : this(name, "$modifiers $type $name = $value;") /** - * Returns an expression that sets the value for this field. + * Declares a non-initialized Java field. + * + * An example usage: + * + * ``` + * val height = FieldDeclaration("public final", PrimitiveName.INT, "height") + * println(height) // `public final int height;` + * ``` + * + * @param modifiers The field modifiers separated with a space. + * @param type The field type. + * @param name The field name. */ - public fun set(value: Expression, useThis: Boolean = false): SetField = - SetField(name, value, useThis) -} - -/** - * Assigns a [value] to a field with the given [name]. - * - * An example usage: - * - * ``` - * val setHeight = SetField("height", Expression("180"), useThis = true) - * println(setHeight) // `this.height = 180;` - * ``` - * - * @param name The field name. - * @param value The value to assign. - * @param explicitThis Tells whether to use the explicit `this` keyword. - */ -public class SetField( - public val name: String, - public val value: Expression, - public val explicitThis: Boolean = false -) : Statement("${field(name, explicitThis)} = $value;") { + public constructor( + modifiers: String, + type: JavaTypeName, + name: String + ) : this(name, "$modifiers $type $name;") /** - * Returns an expression that reads the field value. + * Returns an expression that reads the value of this field. */ public fun read(useThis: Boolean = false): ReadField = ReadField(name, useThis) } From 7738e2d5f8aa5f7a8b0085ffc6237f02fc920829 Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Mon, 17 Feb 2025 12:54:27 +0100 Subject: [PATCH 07/10] Update tests --- ...clFieldSpec.kt => FieldDeclarationSpec.kt} | 44 +++++++++------ .../io/spine/protodata/java/InitFieldSpec.kt | 53 ------------------- 2 files changed, 27 insertions(+), 70 deletions(-) rename java/src/test/kotlin/io/spine/protodata/java/{DeclFieldSpec.kt => FieldDeclarationSpec.kt} (54%) delete mode 100644 java/src/test/kotlin/io/spine/protodata/java/InitFieldSpec.kt diff --git a/java/src/test/kotlin/io/spine/protodata/java/DeclFieldSpec.kt b/java/src/test/kotlin/io/spine/protodata/java/FieldDeclarationSpec.kt similarity index 54% rename from java/src/test/kotlin/io/spine/protodata/java/DeclFieldSpec.kt rename to java/src/test/kotlin/io/spine/protodata/java/FieldDeclarationSpec.kt index df652eda8..7d544092e 100644 --- a/java/src/test/kotlin/io/spine/protodata/java/DeclFieldSpec.kt +++ b/java/src/test/kotlin/io/spine/protodata/java/FieldDeclarationSpec.kt @@ -30,31 +30,41 @@ import assertCode import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -@DisplayName("`DeclField` should") -internal class DeclFieldSpec { +@DisplayName("`FieldDeclaration` should") +internal class FieldDeclarationSpec { - private val surname = DeclField( - modifiers = "private final", - type = ClassName(String::class), - name = "surname" - ) + @Test + fun `declare an arbitrary Java field`() { + val code = "private static String surname = \"\";" + val field = FieldDeclaration("surname", code) + assertCode(field, code) + } @Test - fun `declare a Java field`() { - assertCode(surname, "private final java.lang.String surname;") + fun `declare a non-initialized Java field`() { + val field = FieldDeclaration( + modifiers = "private final", + type = ClassName(String::class), + name = "surname" + ) + assertCode(field, "private final java.lang.String surname;") } @Test - fun `set a value to the declared field`() { - val anderson = "Anderson" - val expression = StringLiteral(anderson) - assertCode(surname.set(expression), "surname = \"$anderson\";") - assertCode(surname.set(expression, useThis = true), "this.surname = \"$anderson\";") + fun `declare an initialized Java field`() { + val field = FieldDeclaration( + modifiers = "private final", + type = ClassName(String::class), + name = "surname", + value = StringLiteral("Anderson") + ) + assertCode(field, "private final java.lang.String surname = \"Anderson\";") } @Test - fun `provide a read access to the declared field`() { - assertCode(surname.read(), "surname") - assertCode(surname.read(useThis = true), "this.surname") + fun `provide a read access to the field`() { + val field = FieldDeclaration("surname", "private static String surname = \"\";") + assertCode(field.read(), "surname") + assertCode(field.read(useThis = true), "this.surname") } } diff --git a/java/src/test/kotlin/io/spine/protodata/java/InitFieldSpec.kt b/java/src/test/kotlin/io/spine/protodata/java/InitFieldSpec.kt deleted file mode 100644 index 3307bcb35..000000000 --- a/java/src/test/kotlin/io/spine/protodata/java/InitFieldSpec.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2024, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.protodata.java - -import assertCode -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test - -@DisplayName("`InitField` should") -internal class InitFieldSpec { - - private val surname = InitField( - modifiers = "private final", - type = ClassName(String::class), - name = "surname", - value = StringLiteral("Anderson") - ) - - @Test - fun `create an initialized Java field`() { - assertCode(surname, "private final java.lang.String surname = \"Anderson\";") - } - - @Test - fun `provide a read access to the created field`() { - assertCode(surname.read(), "surname") - assertCode(surname.read(useThis = true), "this.surname") - } -} From e9bfaf90a16f08e4e528fe29941193a5a28c3b88 Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Mon, 17 Feb 2025 12:55:03 +0100 Subject: [PATCH 08/10] Remove the suggested extension --- .../io/spine/protodata/CompilationErrors.kt | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt diff --git a/api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt b/api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt deleted file mode 100644 index ab3cd46de..000000000 --- a/api/src/main/kotlin/io/spine/protodata/CompilationErrors.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2025, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.protodata - -import io.spine.environment.Tests -import io.spine.protodata.Compilation.ERROR_EXIT_CODE -import io.spine.protodata.ast.File -import io.spine.protodata.ast.Span -import io.spine.protodata.ast.toPath - -/** - * Prints the error diagnostics to [System.err] and terminates the compilation. - * - * The termination of the compilation in the production mode is done by - * exiting the process with [ERROR_EXIT_CODE]. - * - * If the code is run [under tests][Tests] the method throws [Compilation.Error]. - * - * @param file The file in which the error occurred. - * @param span The location span of the erroneous Protobuf declaration. - * @param message The description of what went wrong. - * - * @throws Compilation.Error exception when called under tests. - */ -public fun compilationError(file: File, span: Span, message: () -> String): Nothing = - Compilation.error( - file.toPath().toFile(), - span.startLine, span.startColumn, - message() - ) From 748ecc16e14cf12ad1284a96a2a476386cedbc4c Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Mon, 17 Feb 2025 12:56:10 +0100 Subject: [PATCH 09/10] Bump the version -> `0.92.1` --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index d1e0ba669..58ba76e29 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -32,4 +32,4 @@ * * For dependencies on Spine SDK module please see [io.spine.dependency.local.Spine]. */ -val protoDataVersion: String by extra("0.92.0") +val protoDataVersion: String by extra("0.92.1") From 1981ba9ec8f8de8674b8c1826b02db9008a79eae Mon Sep 17 00:00:00 2001 From: yevhenii-nadtochii Date: Mon, 17 Feb 2025 12:59:26 +0100 Subject: [PATCH 10/10] Update reports --- dependencies.md | 44 ++++++++++++++++++++++---------------------- pom.xml | 16 ++++++++-------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dependencies.md b/dependencies.md index 6d9bc2588..b5f1c2b1c 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.protodata:protodata-api:0.92.0` +# Dependencies of `io.spine.protodata:protodata-api:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -1041,12 +1041,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:54 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:57 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-api-tests:0.92.0` +# Dependencies of `io.spine.protodata:protodata-api-tests:0.92.1` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 13.0. @@ -1894,12 +1894,12 @@ This report was generated on **Sun Feb 16 18:33:54 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:54 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:57 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-backend:0.92.0` +# Dependencies of `io.spine.protodata:protodata-backend:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -2928,12 +2928,12 @@ This report was generated on **Sun Feb 16 18:33:54 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:55 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:58 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-cli:0.92.0` +# Dependencies of `io.spine.protodata:protodata-cli:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -4045,12 +4045,12 @@ This report was generated on **Sun Feb 16 18:33:55 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:55 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:58 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-gradle-api:0.92.0` +# Dependencies of `io.spine.protodata:protodata-gradle-api:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -5061,12 +5061,12 @@ This report was generated on **Sun Feb 16 18:33:55 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:58 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-gradle-plugin:0.92.0` +# Dependencies of `io.spine.protodata:protodata-gradle-plugin:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -6249,12 +6249,12 @@ This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:58 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-java:0.92.0` +# Dependencies of `io.spine.protodata:protodata-java:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -7283,12 +7283,12 @@ This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:59 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-params:0.92.0` +# Dependencies of `io.spine.protodata:protodata-params:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -8324,12 +8324,12 @@ This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:59 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-protoc:0.92.0` +# Dependencies of `io.spine.protodata:protodata-protoc:0.92.1` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -9166,12 +9166,12 @@ This report was generated on **Sun Feb 16 18:33:56 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:57 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:59 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-test-env:0.92.0` +# Dependencies of `io.spine.protodata:protodata-test-env:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -10215,12 +10215,12 @@ This report was generated on **Sun Feb 16 18:33:57 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:57 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Feb 17 12:57:59 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.protodata:protodata-testlib:0.92.0` +# Dependencies of `io.spine.protodata:protodata-testlib:0.92.1` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -11351,4 +11351,4 @@ This report was generated on **Sun Feb 16 18:33:57 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Feb 16 18:33:57 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Mon Feb 17 12:58:00 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 555368308..7c82b4ddc 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.protodata ProtoData -0.92.0 +0.92.1 2015 @@ -131,6 +131,12 @@ all modules and does not describe the project structure per-subproject. 2.0.0-SNAPSHOT.244 compile + + io.spine.tools + spine-testutil-server + 2.0.0-SNAPSHOT.202 + compile + io.spine.tools spine-tool-base @@ -209,12 +215,6 @@ all modules and does not describe the project structure per-subproject. 2.0.0-SNAPSHOT.244 test - - io.spine.tools - spine-testutil-server - 2.0.0-SNAPSHOT.202 - test - io.spine.tools spine-time-testlib @@ -303,7 +303,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools prototap-protoc-plugin - 0.9.0 + 0.9.1 io.spine.tools