From fdc909b1b6d9490f3d1728bc50e146bdaf3204e8 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Thu, 16 Mar 2023 13:31:23 +0200 Subject: [PATCH 01/46] Emit events about all types --- .github/workflows/build-on-ubuntu.yml | 12 +---- .../io/spine/protodata/event/CompilerEvent.kt | 34 ++++++++++++ .../spine/protodata/event/CompilerEvents.kt | 20 +++---- .../protodata/event/EnumCompilerEvents.kt | 14 +++-- .../protodata/event/MessageCompilerEvents.kt | 21 +++++--- .../protodata/event/OptionsCompilerEvents.kt | 5 +- .../protodata/event/ServiceCompilerEvents.kt | 14 +++-- .../main/proto/spine/protodata/events.proto | 49 +++++++++++++++++ .../protodata/event/CompilerEventsSpec.kt | 4 +- .../io/spine/internal/dependency/Pmd.kt | 2 +- .../io/spine/internal/dependency/Spine.kt | 6 +-- config | 2 +- license-report.md | 53 +++++++++---------- pom.xml | 20 +++---- 14 files changed, 174 insertions(+), 82 deletions(-) create mode 100644 api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt diff --git a/.github/workflows/build-on-ubuntu.yml b/.github/workflows/build-on-ubuntu.yml index b09342f69..4029252ac 100644 --- a/.github/workflows/build-on-ubuntu.yml +++ b/.github/workflows/build-on-ubuntu.yml @@ -22,23 +22,13 @@ jobs: run: ./gradlew build --stacktrace # See: https://github.com/marketplace/actions/junit-report-action - - name: Publish Unit Test Report + - name: Publish Test Report uses: mikepenz/action-junit-report@v3.5.2 if: always() # always run even if the previous step fails with: - check_name: Regular Unit Tests report_paths: '**/build/test-results/test/TEST-*.xml' require_tests: true # will fail workflow if test reports not found - # See: https://github.com/marketplace/actions/junit-report-action - - name: Publish Functional Test Report - uses: mikepenz/action-junit-report@v3.5.2 - if: always() # always run even if the previous step fails - with: - check_name: Functional Tests - report_paths: 'gradle-plugin/build/test-results/functionalTest/TEST-*.xml' - require_tests: true # will fail workflow if test reports not found - - name: Upload code coverage report uses: codecov/codecov-action@v3 with: diff --git a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt new file mode 100644 index 000000000..4ec97174d --- /dev/null +++ b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2023, 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 + * + * http://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.event + +import io.spine.base.EventMessage + +public interface CompilerEvent : EventMessage { + + public fun getGenerationRequested(): Boolean +} diff --git a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt index 7c5edba66..bb3ab10fe 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt +++ b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt @@ -28,7 +28,6 @@ package io.spine.protodata.event import com.google.protobuf.Descriptors.FileDescriptor import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest -import io.spine.base.EventMessage import io.spine.code.proto.FileSet import io.spine.protodata.Documentation import io.spine.protodata.File @@ -46,13 +45,12 @@ public object CompilerEvents { * * The resulting sequence is always finite, it's limited by the type set. */ - public fun parse(request: CodeGeneratorRequest): Sequence { + public fun parse(request: CodeGeneratorRequest): Sequence { val filesToGenerate = request.fileToGenerateList.toSet() val files = FileSet.of(request.protoFileList) return sequence { files.files() - .filter { it.name in filesToGenerate } - .map(::ProtoFileEvents) + .map { ProtoFileEvents(it, it.name in filesToGenerate) } .forEach { it.apply { produceFileEvents() } } } } @@ -62,7 +60,8 @@ public object CompilerEvents { * Produces events from the associated file. */ private class ProtoFileEvents( - private val fileDescriptor: FileDescriptor + private val fileDescriptor: FileDescriptor, + private val shouldGenerate: Boolean ) { private val file = File.newBuilder() @@ -81,34 +80,37 @@ private class ProtoFileEvents( * Opens with an [FileEntered] event. Then go the events regarding the file metadata. Then go * the events regarding the file contents. At last, closes with an [FileExited] event. */ - suspend fun SequenceScope.produceFileEvents() { + suspend fun SequenceScope.produceFileEvents() { yield( FileEntered.newBuilder() .setPath(file.path) .setFile(file) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(fileDescriptor.options) { FileOptionDiscovered.newBuilder() .setFile(file.path) .setOption(it) + .setGenerationRequested(shouldGenerate) .build() } - val messageEvents = MessageCompilerEvents(file, documentation) + val messageEvents = MessageCompilerEvents(file, documentation, shouldGenerate) fileDescriptor.messageTypes.forEach { messageEvents.apply { produceMessageEvents(it) } } - val enumEvents = EnumCompilerEvents(file, documentation) + val enumEvents = EnumCompilerEvents(file, documentation, shouldGenerate) fileDescriptor.enumTypes.forEach { enumEvents.apply { produceEnumEvents(it) } } - val serviceEvents = ServiceCompilerEvents(file, documentation) + val serviceEvents = ServiceCompilerEvents(file, documentation, shouldGenerate) fileDescriptor.services.forEach { serviceEvents.apply { produceServiceEvents(it) } } yield( FileExited.newBuilder() .setFile(file.path) + .setGenerationRequested(shouldGenerate) .build() ) } diff --git a/api/src/main/kotlin/io/spine/protodata/event/EnumCompilerEvents.kt b/api/src/main/kotlin/io/spine/protodata/event/EnumCompilerEvents.kt index 600027788..0ec30f8e8 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/EnumCompilerEvents.kt +++ b/api/src/main/kotlin/io/spine/protodata/event/EnumCompilerEvents.kt @@ -27,7 +27,6 @@ package io.spine.protodata.event import com.google.protobuf.Descriptors -import io.spine.base.EventMessage import io.spine.protodata.ConstantName import io.spine.protodata.Documentation import io.spine.protodata.EnumConstant @@ -41,7 +40,8 @@ import io.spine.protodata.name */ internal class EnumCompilerEvents( private val file: File, - private val documentation: Documentation + private val documentation: Documentation, + private val shouldGenerate: Boolean ) { /** @@ -50,7 +50,7 @@ internal class EnumCompilerEvents( * Opens with an [EnumEntered] event. Then go the events regarding the type metadata. Then go * the events regarding the enum constants. At last, closes with an [EnumExited] event. */ - internal suspend fun SequenceScope.produceEnumEvents( + internal suspend fun SequenceScope.produceEnumEvents( descriptor: Descriptors.EnumDescriptor, nestedIn: TypeName? = null ) { @@ -68,6 +68,7 @@ internal class EnumCompilerEvents( EnumEntered.newBuilder() .setFile(path) .setType(type) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(descriptor.options) { @@ -75,6 +76,7 @@ internal class EnumCompilerEvents( .setFile(path) .setType(typeName) .setOption(it) + .setGenerationRequested(shouldGenerate) .build() } descriptor.values.forEach { @@ -84,6 +86,7 @@ internal class EnumCompilerEvents( EnumExited.newBuilder() .setFile(path) .setType(typeName) + .setGenerationRequested(shouldGenerate) .build() ) } @@ -94,7 +97,7 @@ internal class EnumCompilerEvents( * Opens with an [EnumConstantEntered] event. Then go the events regarding the constant options. * At last, closes with an [EnumConstantExited] event. */ - private suspend fun SequenceScope.produceConstantEvents( + private suspend fun SequenceScope.produceConstantEvents( type: TypeName, descriptor: Descriptors.EnumValueDescriptor ) { @@ -114,6 +117,7 @@ internal class EnumCompilerEvents( .setFile(path) .setType(type) .setConstant(constant) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(descriptor.options) { @@ -121,6 +125,7 @@ internal class EnumCompilerEvents( .setFile(path) .setType(type) .setConstant(name) + .setGenerationRequested(shouldGenerate) .build() } yield( @@ -128,6 +133,7 @@ internal class EnumCompilerEvents( .setFile(path) .setType(type) .setConstant(name) + .setGenerationRequested(shouldGenerate) .build() ) } diff --git a/api/src/main/kotlin/io/spine/protodata/event/MessageCompilerEvents.kt b/api/src/main/kotlin/io/spine/protodata/event/MessageCompilerEvents.kt index 7f70d3713..f9a58d5be 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/MessageCompilerEvents.kt +++ b/api/src/main/kotlin/io/spine/protodata/event/MessageCompilerEvents.kt @@ -28,7 +28,6 @@ package io.spine.protodata.event import com.google.protobuf.Descriptors import com.google.protobuf.Empty -import io.spine.base.EventMessage import io.spine.protodata.Documentation import io.spine.protodata.Field import io.spine.protodata.File @@ -42,7 +41,8 @@ import io.spine.protodata.name */ internal class MessageCompilerEvents( private val file: File, - private val documentation: Documentation + private val documentation: Documentation, + private val shouldGenerate: Boolean ) { /** @@ -51,7 +51,7 @@ internal class MessageCompilerEvents( * Opens with an [TypeEntered] event. Then go the events regarding the type metadata. Then go * the events regarding the fields. At last, closes with an [TypeExited] event. */ - internal suspend fun SequenceScope.produceMessageEvents( + internal suspend fun SequenceScope.produceMessageEvents( descriptor: Descriptors.Descriptor, nestedIn: TypeName? = null ) { @@ -69,6 +69,7 @@ internal class MessageCompilerEvents( TypeEntered.newBuilder() .setFile(path) .setType(type) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(descriptor.options) { @@ -76,6 +77,7 @@ internal class MessageCompilerEvents( .setFile(path) .setType(typeName) .setOption(it) + .setGenerationRequested(shouldGenerate) .build() } @@ -89,7 +91,7 @@ internal class MessageCompilerEvents( produceMessageEvents(nestedIn = typeName, descriptor = it) } - val enums = EnumCompilerEvents(file, documentation) + val enums = EnumCompilerEvents(file, documentation, shouldGenerate) descriptor.enumTypes.forEach { enums.apply { produceEnumEvents(nestedIn = typeName, descriptor = it) @@ -100,6 +102,7 @@ internal class MessageCompilerEvents( TypeExited.newBuilder() .setFile(path) .setType(typeName) + .setGenerationRequested(shouldGenerate) .build() ) } @@ -110,7 +113,7 @@ internal class MessageCompilerEvents( * Opens with an [OneofGroupEntered] event. Then go the events regarding the group metadata. * Then go the events regarding the fields. At last, closes with an [OneofGroupExited] event. */ - private suspend fun SequenceScope.produceOneofEvents( + private suspend fun SequenceScope.produceOneofEvents( type: TypeName, descriptor: Descriptors.OneofDescriptor ) { @@ -125,6 +128,7 @@ internal class MessageCompilerEvents( .setFile(path) .setType(type) .setGroup(oneofGroup) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(descriptor.options) { @@ -133,6 +137,7 @@ internal class MessageCompilerEvents( .setType(type) .setGroup(oneofName) .setOption(it) + .setGenerationRequested(shouldGenerate) .build() } descriptor.fields.forEach { produceFieldEvents(type, it) } @@ -141,6 +146,7 @@ internal class MessageCompilerEvents( .setFile(path) .setType(type) .setGroup(oneofName) + .setGenerationRequested(shouldGenerate) .build() ) } @@ -151,7 +157,7 @@ internal class MessageCompilerEvents( * Opens with an [FieldEntered] event. Then go the events regarding the field options. At last, * closes with an [FieldExited] event. */ - private suspend fun SequenceScope.produceFieldEvents( + private suspend fun SequenceScope.produceFieldEvents( type: TypeName, descriptor: Descriptors.FieldDescriptor ) { @@ -170,6 +176,7 @@ internal class MessageCompilerEvents( .setFile(path) .setType(type) .setField(field) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(descriptor.options) { @@ -178,6 +185,7 @@ internal class MessageCompilerEvents( .setType(type) .setField(fieldName) .setOption(it) + .setGenerationRequested(shouldGenerate) .build() } yield( @@ -185,6 +193,7 @@ internal class MessageCompilerEvents( .setFile(path) .setType(type) .setField(fieldName) + .setGenerationRequested(shouldGenerate) .build() ) } diff --git a/api/src/main/kotlin/io/spine/protodata/event/OptionsCompilerEvents.kt b/api/src/main/kotlin/io/spine/protodata/event/OptionsCompilerEvents.kt index ae61e422f..634478b9a 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/OptionsCompilerEvents.kt +++ b/api/src/main/kotlin/io/spine/protodata/event/OptionsCompilerEvents.kt @@ -31,7 +31,6 @@ import com.google.protobuf.Descriptors.FieldDescriptor import com.google.protobuf.Descriptors.FieldDescriptor.Type.ENUM import com.google.protobuf.EnumValue import com.google.protobuf.GeneratedMessageV3 -import io.spine.base.EventMessage import io.spine.protobuf.AnyPacker import io.spine.protobuf.TypeConverter import io.spine.protodata.Option @@ -44,9 +43,9 @@ import io.spine.protodata.Option * @param ctor * a function which given an option, constructs a fitting event */ -internal suspend fun SequenceScope.produceOptionEvents( +internal suspend fun SequenceScope.produceOptionEvents( options: GeneratedMessageV3.ExtendableMessage<*>, - ctor: (Option) -> EventMessage + ctor: (Option) -> CompilerEvent ) { options.allFields.forEach { (optionDescriptor, value) -> if(value is Collection<*>) { diff --git a/api/src/main/kotlin/io/spine/protodata/event/ServiceCompilerEvents.kt b/api/src/main/kotlin/io/spine/protodata/event/ServiceCompilerEvents.kt index 33fc88c58..39ff247e4 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/ServiceCompilerEvents.kt +++ b/api/src/main/kotlin/io/spine/protodata/event/ServiceCompilerEvents.kt @@ -27,7 +27,6 @@ package io.spine.protodata.event import com.google.protobuf.Descriptors -import io.spine.base.EventMessage import io.spine.protodata.Documentation import io.spine.protodata.File import io.spine.protodata.Rpc @@ -41,7 +40,8 @@ import io.spine.protodata.name */ internal class ServiceCompilerEvents( private val file: File, - private val documentation: Documentation + private val documentation: Documentation, + private val shouldGenerate: Boolean ) { /** @@ -50,7 +50,7 @@ internal class ServiceCompilerEvents( * Opens with an [ServiceEntered] event. Then go the events regarding the service metadata. * Then go the events regarding the RPC methods. At last, closes with an [ServiceExited] event. */ - internal suspend fun SequenceScope.produceServiceEvents( + internal suspend fun SequenceScope.produceServiceEvents( descriptor: Descriptors.ServiceDescriptor ) { val serviceName = descriptor.name() @@ -63,6 +63,7 @@ internal class ServiceCompilerEvents( ServiceEntered.newBuilder() .setFile(path) .setService(service) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(descriptor.options) { @@ -70,6 +71,7 @@ internal class ServiceCompilerEvents( .setFile(path) .setService(serviceName) .setOption(it) + .setGenerationRequested(shouldGenerate) .build() } descriptor.methods.forEach { produceRpcEvents(serviceName, it) } @@ -77,11 +79,12 @@ internal class ServiceCompilerEvents( ServiceExited.newBuilder() .setFile(path) .setService(serviceName) + .setGenerationRequested(shouldGenerate) .build() ) } - private suspend fun SequenceScope.produceRpcEvents( + private suspend fun SequenceScope.produceRpcEvents( service: ServiceName, descriptor: Descriptors.MethodDescriptor ) { @@ -101,6 +104,7 @@ internal class ServiceCompilerEvents( .setFile(path) .setService(service) .setRpc(rpc) + .setGenerationRequested(shouldGenerate) .build() ) produceOptionEvents(descriptor.options) { @@ -109,6 +113,7 @@ internal class ServiceCompilerEvents( .setService(service) .setRpc(name) .setOption(it) + .setGenerationRequested(shouldGenerate) .build() } yield( @@ -116,6 +121,7 @@ internal class ServiceCompilerEvents( .setFile(path) .setService(service) .setRpc(name) + .setGenerationRequested(shouldGenerate) .build() ) } diff --git a/api/src/main/proto/spine/protodata/events.proto b/api/src/main/proto/spine/protodata/events.proto index 543c7ce78..f9010cd1e 100644 --- a/api/src/main/proto/spine/protodata/events.proto +++ b/api/src/main/proto/spine/protodata/events.proto @@ -34,6 +34,7 @@ option (type_url_prefix) = "type.spine.io"; option java_package = "io.spine.protodata.event"; option java_outer_classname = "EventsProto"; option java_multiple_files = true; +option (every_is).java_type = "CompilerEvent"; import "spine/protodata/ast.proto"; @@ -43,6 +44,8 @@ message FileEntered { FilePath path = 1; File file = 2; + + bool generation_requested = 3; } // Emitted when a file-level option is found. @@ -51,12 +54,16 @@ message FileOptionDiscovered { FilePath file = 1; Option option = 2; + + bool generation_requested = 3; } // Emitted when a file is completely discovered, including all the types, etc. message FileExited { FilePath file = 1; + + bool generation_requested = 2; } // Emitted when processing reaches a message type. @@ -65,6 +72,8 @@ message TypeEntered { FilePath file = 1; MessageType type = 2; + + bool generation_requested = 3; } // Emitted when a message-level option is found. @@ -75,6 +84,8 @@ message TypeOptionDiscovered { TypeName type = 2; Option option = 3; + + bool generation_requested = 4; } // Emitted when a message type is completely discovered, including all the fields, etc. @@ -83,6 +94,8 @@ message TypeExited { FilePath file = 1; TypeName type = 2; + + bool generation_requested = 3; } // Emitted when processing reaches a `oneof` group. @@ -93,6 +106,8 @@ message OneofGroupEntered { TypeName type = 2; OneofGroup group = 3; + + bool generation_requested = 4; } // Emitted when a `oneof`-level option is found. @@ -105,6 +120,8 @@ message OneofOptionDiscovered { OneofName group = 3; Option option = 4; + + bool generation_requested = 5; } // Emitted when a `oneof`-group is completely discovered, including all the options and fields. @@ -115,6 +132,8 @@ message OneofGroupExited { TypeName type = 2; OneofName group = 3; + + bool generation_requested = 4; } // Emitted when processing reaches a field. @@ -125,6 +144,8 @@ message FieldEntered { TypeName type = 2; Field field = 3; + + bool generation_requested = 4; } // Emitted when a field-level option is found. @@ -137,6 +158,8 @@ message FieldOptionDiscovered { FieldName field = 3; Option option = 4; + + bool generation_requested = 5; } // Emitted when a field is completely discovered including the options. @@ -147,6 +170,8 @@ message FieldExited { TypeName type = 2; FieldName field = 3; + + bool generation_requested = 4; } // Emitted when processing reaches an enum type. @@ -155,6 +180,8 @@ message EnumEntered { FilePath file = 1; EnumType type = 2; + + bool generation_requested = 3; } // Emitted when an enum-level option is found. @@ -165,6 +192,8 @@ message EnumOptionDiscovered { TypeName type = 2; Option option = 3; + + bool generation_requested = 4; } // Emitted when processing reaches an enum constant a.k.a. enum value. @@ -175,6 +204,8 @@ message EnumConstantEntered { TypeName type = 2; EnumConstant constant = 3; + + bool generation_requested = 4; } // Emitted when an enum constant-level option is found. @@ -187,6 +218,8 @@ message EnumConstantOptionDiscovered { ConstantName constant = 3; Option option = 4; + + bool generation_requested = 5; } // Emitted when an enum constant is completely discovered. @@ -197,6 +230,8 @@ message EnumConstantExited { TypeName type = 2; ConstantName constant = 3; + + bool generation_requested = 4; } // Emitted when an enum type is completely discovered, including all the constants, etc. @@ -205,6 +240,8 @@ message EnumExited { FilePath file = 1; TypeName type = 2; + + bool generation_requested = 3; } // Emitted when the processing reaches a service. @@ -213,6 +250,8 @@ message ServiceEntered { FilePath file = 1; Service service = 2; + + bool generation_requested = 3; } // Emitted when an service-level option is found. @@ -223,6 +262,8 @@ message ServiceOptionDiscovered { ServiceName service = 2; Option option = 3; + + bool generation_requested = 4; } // Emitted when a service is completely discovered, including all the option and RPCs. @@ -231,6 +272,8 @@ message ServiceExited { FilePath file = 1; ServiceName service = 2; + + bool generation_requested = 3; } // Emitted when the processing reaches a remote procedure call. @@ -241,6 +284,8 @@ message RpcEntered { ServiceName service = 2; Rpc rpc = 3; + + bool generation_requested = 4; } // Emitted when an RPC-level option is found. @@ -253,6 +298,8 @@ message RpcOptionDiscovered { RpcName rpc = 3; Option option = 4; + + bool generation_requested = 5; } // Emitted when an RPC is completely discovered. @@ -263,4 +310,6 @@ message RpcExited { ServiceName service = 2; RpcName rpc = 3; + + bool generation_requested = 4; } diff --git a/api/src/test/kotlin/io/spine/protodata/event/CompilerEventsSpec.kt b/api/src/test/kotlin/io/spine/protodata/event/CompilerEventsSpec.kt index 04c9ebf1b..adf3ab6b0 100644 --- a/api/src/test/kotlin/io/spine/protodata/event/CompilerEventsSpec.kt +++ b/api/src/test/kotlin/io/spine/protodata/event/CompilerEventsSpec.kt @@ -56,7 +56,7 @@ class CompilerEventsSpec { private val nl: String = System.lineSeparator() - private lateinit var events: List + private lateinit var events: List @BeforeEach fun parseEvents() { @@ -69,7 +69,7 @@ class CompilerEventsSpec { fileToGenerate += DoctorProto.getDescriptor().fullName protoFile.addAll(allTheTypes) } - events = CompilerEvents.parse(request).toList() + events = CompilerEvents.parse(request).filter { it.getGenerationRequested() }.toList() } @Nested diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Pmd.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Pmd.kt index c4a1e00aa..ca997750b 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Pmd.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Pmd.kt @@ -28,5 +28,5 @@ package io.spine.internal.dependency // https://pmd.github.io/ object Pmd { - const val version = "6.51.0" + const val version = "6.55.0" } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Spine.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Spine.kt index db644f4a9..dc1aec825 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Spine.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Spine.kt @@ -61,7 +61,7 @@ class Spine(p: ExtensionAware) { * * @see [ProtoData] */ - const val protoData = "0.7.4" + const val protoData = "0.7.6" /** * The default version of `base` to use. @@ -85,7 +85,7 @@ class Spine(p: ExtensionAware) { /** * The version of `mc-java` to use. */ - const val mcJava = "2.0.0-SNAPSHOT.134" + const val mcJava = "2.0.0-SNAPSHOT.132" /** * The version of `base-types` to use. @@ -116,7 +116,7 @@ class Spine(p: ExtensionAware) { * The version of `tool-base` to use. * @see [Spine.toolBase] */ - const val toolBase = "2.0.0-SNAPSHOT.161" + const val toolBase = "2.0.0-SNAPSHOT.156" /** * The version of `validation` to use. diff --git a/config b/config index 1eed7ff05..766e0a728 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 1eed7ff05c1eef99b80afc90e481948037df4595 +Subproject commit 766e0a728ef7304a5fe6392d11714ca1e468f70f diff --git a/license-report.md b/license-report.md index ca7647888..7e5f1faec 100644 --- a/license-report.md +++ b/license-report.md @@ -111,7 +111,7 @@ * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -520,9 +520,8 @@ * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-bundle. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-bundle. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -897,7 +896,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:42 EET 2023** 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 **Thu Mar 16 13:00:39 EET 2023** 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). @@ -1018,7 +1017,7 @@ This report was generated on **Fri Mar 03 16:18:42 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -1431,7 +1430,6 @@ This report was generated on **Fri Mar 03 16:18:42 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -1802,7 +1800,7 @@ This report was generated on **Fri Mar 03 16:18:42 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:43 EET 2023** 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 **Thu Mar 16 13:00:40 EET 2023** 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). @@ -1918,7 +1916,7 @@ This report was generated on **Fri Mar 03 16:18:43 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -2314,7 +2312,6 @@ This report was generated on **Fri Mar 03 16:18:43 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -2684,7 +2681,7 @@ This report was generated on **Fri Mar 03 16:18:43 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:44 EET 2023** 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 **Thu Mar 16 13:00:41 EET 2023** 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). @@ -2800,7 +2797,7 @@ This report was generated on **Fri Mar 03 16:18:44 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -3205,7 +3202,6 @@ This report was generated on **Fri Mar 03 16:18:44 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -3568,7 +3564,7 @@ This report was generated on **Fri Mar 03 16:18:44 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:44 EET 2023** 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 **Thu Mar 16 13:00:42 EET 2023** 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). @@ -3684,7 +3680,7 @@ This report was generated on **Fri Mar 03 16:18:44 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -4094,7 +4090,6 @@ This report was generated on **Fri Mar 03 16:18:44 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -4469,7 +4464,7 @@ This report was generated on **Fri Mar 03 16:18:44 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:45 EET 2023** 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 **Thu Mar 16 13:00:43 EET 2023** 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). @@ -4524,7 +4519,7 @@ This report was generated on **Fri Mar 03 16:18:45 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/square/javapoet/](https://github.com/square/javapoet/) * **License:** [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -4701,7 +4696,7 @@ This report was generated on **Fri Mar 03 16:18:45 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/google/j2objc/](https://github.com/google/j2objc/) * **License:** [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.2. +1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.1. * **Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) * **License:** [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) @@ -4894,7 +4889,6 @@ This report was generated on **Fri Mar 03 16:18:45 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -5260,7 +5254,7 @@ This report was generated on **Fri Mar 03 16:18:45 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:46 EET 2023** 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 **Thu Mar 16 13:00:44 EET 2023** 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). @@ -5376,7 +5370,7 @@ This report was generated on **Fri Mar 03 16:18:46 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -5607,6 +5601,10 @@ This report was generated on **Fri Mar 03 16:18:46 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/google/j2objc/](https://github.com/google/j2objc/) * **License:** [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.1. + * **Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) + * **License:** [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) + 1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.2. * **Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) * **License:** [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) @@ -5800,7 +5798,6 @@ This report was generated on **Fri Mar 03 16:18:46 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -6270,7 +6267,7 @@ This report was generated on **Fri Mar 03 16:18:46 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:47 EET 2023** 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 **Thu Mar 16 13:00:45 EET 2023** 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). @@ -7026,7 +7023,7 @@ This report was generated on **Fri Mar 03 16:18:47 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:48 EET 2023** 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 **Thu Mar 16 13:00:46 EET 2023** 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). @@ -7142,7 +7139,7 @@ This report was generated on **Fri Mar 03 16:18:48 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -7549,8 +7546,8 @@ This report was generated on **Fri Mar 03 16:18:48 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-bundle. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-bundle. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -7921,4 +7918,4 @@ This report was generated on **Fri Mar 03 16:18:48 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 03 16:18:48 EET 2023** 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 **Thu Mar 16 13:00:46 EET 2023** 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 180db3600..698a6627e 100644 --- a/pom.xml +++ b/pom.xml @@ -98,13 +98,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-tool-base - 2.0.0-SNAPSHOT.161 + 2.0.0-SNAPSHOT.156 compile io.spine.validation spine-validation-java-runtime - 2.0.0-SNAPSHOT.81 + 2.0.0-SNAPSHOT.80 compile @@ -158,7 +158,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-plugin-testlib - 2.0.0-SNAPSHOT.161 + 2.0.0-SNAPSHOT.156 test @@ -210,7 +210,7 @@ all modules and does not describe the project structure per-subproject. com.google.protobuf protoc - 3.22.0 + 3.21.12 io.gitlab.arturbosch.detekt @@ -225,28 +225,28 @@ all modules and does not describe the project structure per-subproject. io.spine.protodata protodata-fat-cli - 0.7.3 + 0.6.1 io.spine.protodata protodata-protoc - 0.7.3 + 0.6.1 io.spine.tools spine-mc-java-checks - 2.0.0-SNAPSHOT.134 + 2.0.0-SNAPSHOT.132 provided io.spine.tools spine-mc-java-plugins - 2.0.0-SNAPSHOT.134 + 2.0.0-SNAPSHOT.132 io.spine.tools spine-plugin-base - 2.0.0-SNAPSHOT.161 + 2.0.0-SNAPSHOT.156 io.spine.tools @@ -256,7 +256,7 @@ all modules and does not describe the project structure per-subproject. io.spine.validation spine-validation-java-bundle - 2.0.0-SNAPSHOT.81 + 2.0.0-SNAPSHOT.80 org.jacoco From a4f32dffcab6d36cf8d67924ab28ee8d3216cbdb Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Thu, 16 Mar 2023 17:17:18 +0200 Subject: [PATCH 02/46] Add a test for non-request files --- .../main/proto/spine/protodata/source.proto | 3 + .../protodata/backend/ProtoSourceFileView.kt | 1 + .../backend/CodeGenerationContextSpec.kt | 96 ++++++++++++------- license-report.md | 18 ++-- 4 files changed, 73 insertions(+), 45 deletions(-) diff --git a/api/src/main/proto/spine/protodata/source.proto b/api/src/main/proto/spine/protodata/source.proto index dd75c3537..8d992ccd9 100644 --- a/api/src/main/proto/spine/protodata/source.proto +++ b/api/src/main/proto/spine/protodata/source.proto @@ -69,4 +69,7 @@ message ProtobufSourceFile { // The keys are the type URLs of the services. // map service = 5; + + // Shows if ProtoData renderers should generate code for this Protobuf definition. + bool generation_requested = 6; } diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt index 0da166c43..407940cd9 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt @@ -71,6 +71,7 @@ internal class ProtoSourceFileView update { filePath = e.file.path file = e.file + generationRequested = e.generationRequested } } diff --git a/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt b/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt index ffa5f577c..685f18814 100644 --- a/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt +++ b/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt @@ -27,6 +27,7 @@ package io.spine.protodata.backend import com.google.common.truth.Truth.assertThat +import com.google.protobuf.AnyProto import com.google.protobuf.BoolValue import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest import io.spine.option.OptionsProto.BETA_TYPE_FIELD_NUMBER @@ -41,7 +42,9 @@ import io.spine.protodata.test.DoctorProto import io.spine.protodata.typeUrl import io.spine.testing.server.blackbox.BlackBox import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import com.google.common.truth.extensions.proto.ProtoTruth.assertThat as assertMessage @@ -54,45 +57,66 @@ class CodeGenerationContextSpec { assertTrue(ctx.hasEntitiesOfType(ProtoSourceFileView::class.java)) } - @Test - fun `construct 'ProtobufSource' based on a descriptor set`() { - val ctx = BlackBox.from(CodeGenerationContext.builder()) - val protoDescriptor = DoctorProto.getDescriptor().toProto() - val set = CodeGeneratorRequest.newBuilder() - .addProtoFile(protoDescriptor) - .addFileToGenerate(protoDescriptor.name) - .build() - ProtobufCompilerContext().use { - it.emitted(CompilerEvents.parse(set)) + @Nested + inner class `construct 'ProtobufSource' based on a descriptor set with` { + + private lateinit var ctx: BlackBox + + @BeforeEach + fun buildViews() { + ctx = BlackBox.from(CodeGenerationContext.builder()) + val protoDescriptor = DoctorProto.getDescriptor().toProto() + val set = CodeGeneratorRequest.newBuilder() + .addProtoFile(protoDescriptor) + .addProtoFile(AnyProto.getDescriptor().toProto()) + .addFileToGenerate(protoDescriptor.name) + .build() + ProtobufCompilerContext().use { + it.emitted(CompilerEvents.parse(set)) + } } - val path = DoctorProto.getDescriptor().path() - val assertSourceFile = ctx.assertEntity(path, ProtoSourceFileView::class.java) - assertSourceFile - .exists() - val actual = assertSourceFile.actual()!!.state() as ProtobufSourceFile + @Test + fun `files marked for generation`() { + val assertSourceFile = ctx.assertEntity( + DoctorProto.getDescriptor().path(), ProtoSourceFileView::class.java + ) + assertSourceFile + .exists() + val actual = assertSourceFile.actual()!!.state() as ProtobufSourceFile - val types = actual.typeMap - val typeName = "type.spine.io/spine.protodata.test.Journey" - assertThat(types) - .containsKey(typeName) - val journeyType = types[typeName]!! - assertThat(journeyType.name.typeUrl()) - .isEqualTo(typeName) - assertMessage(journeyType.optionList) - .containsExactly( - Option.newBuilder() - .setName("beta_type") - .setNumber(BETA_TYPE_FIELD_NUMBER) - .setType(TYPE_BOOL.asType()) - .setValue(AnyPacker.pack(BoolValue.of(true))) - .build() + val types = actual.typeMap + val typeName = "type.spine.io/spine.protodata.test.Journey" + assertThat(types) + .containsKey(typeName) + val journeyType = types[typeName]!! + assertThat(journeyType.name.typeUrl()) + .isEqualTo(typeName) + assertMessage(journeyType.optionList) + .containsExactly( + Option.newBuilder() + .setName("beta_type") + .setNumber(BETA_TYPE_FIELD_NUMBER) + .setType(TYPE_BOOL.asType()) + .setValue(AnyPacker.pack(BoolValue.of(true))) + .build() + ) + assertThat(journeyType.fieldList) + .hasSize(4) + assertThat(journeyType.oneofGroupList) + .hasSize(1) + assertThat(journeyType.oneofGroupList[0].fieldList) + .hasSize(2) + } + + @Test + fun dependencies() { + val assertSourceFile = ctx.assertEntity( + AnyProto.getDescriptor().path(), + ProtoSourceFileView::class.java ) - assertThat(journeyType.fieldList) - .hasSize(4) - assertThat(journeyType.oneofGroupList) - .hasSize(1) - assertThat(journeyType.oneofGroupList[0].fieldList) - .hasSize(2) + assertSourceFile + .exists() + } } } diff --git a/license-report.md b/license-report.md index 7e5f1faec..5c0278485 100644 --- a/license-report.md +++ b/license-report.md @@ -896,7 +896,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:39 EET 2023** 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 **Thu Mar 16 14:18:34 EET 2023** 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). @@ -1800,7 +1800,7 @@ This report was generated on **Thu Mar 16 13:00:39 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:40 EET 2023** 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 **Thu Mar 16 14:18:35 EET 2023** 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). @@ -2681,7 +2681,7 @@ This report was generated on **Thu Mar 16 13:00:40 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:41 EET 2023** 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 **Thu Mar 16 14:18:36 EET 2023** 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). @@ -3564,7 +3564,7 @@ This report was generated on **Thu Mar 16 13:00:41 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:42 EET 2023** 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 **Thu Mar 16 14:18:37 EET 2023** 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). @@ -4464,7 +4464,7 @@ This report was generated on **Thu Mar 16 13:00:42 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:43 EET 2023** 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 **Thu Mar 16 14:18:38 EET 2023** 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). @@ -5254,7 +5254,7 @@ This report was generated on **Thu Mar 16 13:00:43 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:44 EET 2023** 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 **Thu Mar 16 14:18:39 EET 2023** 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). @@ -6267,7 +6267,7 @@ This report was generated on **Thu Mar 16 13:00:44 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:45 EET 2023** 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 **Thu Mar 16 14:18:40 EET 2023** 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). @@ -7023,7 +7023,7 @@ This report was generated on **Thu Mar 16 13:00:45 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:46 EET 2023** 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 **Thu Mar 16 14:18:41 EET 2023** 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). @@ -7918,4 +7918,4 @@ This report was generated on **Thu Mar 16 13:00:46 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 13:00:46 EET 2023** 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 **Thu Mar 16 14:18:42 EET 2023** 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 From 1534077181792609d8ff7cab4b513ab80582d452 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 17 Mar 2023 11:35:27 +0200 Subject: [PATCH 03/46] Bump version --- license-report.md | 66 ++++++++++++++++++++++++---------------------- pom.xml | 8 +++--- version.gradle.kts | 3 ++- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/license-report.md b/license-report.md index 5c0278485..205e00cff 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.protodata:protodata-api:0.7.6` +# Dependencies of `io.spine.protodata:protodata-api:0.7.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.13.4.**No license information found** @@ -111,7 +111,7 @@ * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -522,6 +522,7 @@ 1. **Group** : io.spine.validation. **Name** : spine-validation-java-bundle. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -896,12 +897,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:34 EET 2023** 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 Mar 17 11:30:14 EET 2023** 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.7.6` +# Dependencies of `io.spine.protodata:protodata-cli:0.7.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.13.4.**No license information found** @@ -1017,7 +1018,7 @@ This report was generated on **Thu Mar 16 14:18:34 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -1430,6 +1431,7 @@ This report was generated on **Thu Mar 16 14:18:34 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -1800,12 +1802,12 @@ This report was generated on **Thu Mar 16 14:18:34 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:35 EET 2023** 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 Mar 17 11:30:15 EET 2023** 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-api:0.7.6` +# Dependencies of `io.spine.protodata:protodata-cli-api:0.7.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.13.4.**No license information found** @@ -1916,7 +1918,7 @@ This report was generated on **Thu Mar 16 14:18:35 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -2312,6 +2314,7 @@ This report was generated on **Thu Mar 16 14:18:35 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -2681,12 +2684,12 @@ This report was generated on **Thu Mar 16 14:18:35 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:36 EET 2023** 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 Mar 17 11:30:16 EET 2023** 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-codegen-java:0.7.6` +# Dependencies of `io.spine.protodata:protodata-codegen-java:0.7.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.13.4.**No license information found** @@ -2797,7 +2800,7 @@ This report was generated on **Thu Mar 16 14:18:36 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -3202,6 +3205,7 @@ This report was generated on **Thu Mar 16 14:18:36 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -3564,12 +3568,12 @@ This report was generated on **Thu Mar 16 14:18:36 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:37 EET 2023** 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 Mar 17 11:30:17 EET 2023** 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-compiler:0.7.6` +# Dependencies of `io.spine.protodata:protodata-compiler:0.7.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.13.4.**No license information found** @@ -3680,7 +3684,7 @@ This report was generated on **Thu Mar 16 14:18:37 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -4090,6 +4094,7 @@ This report was generated on **Thu Mar 16 14:18:37 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -4464,12 +4469,12 @@ This report was generated on **Thu Mar 16 14:18:37 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:38 EET 2023** 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 Mar 17 11:30:18 EET 2023** 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.7.6` +# Dependencies of `io.spine.protodata:protodata-gradle-api:0.7.7` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -4519,7 +4524,7 @@ This report was generated on **Thu Mar 16 14:18:38 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/square/javapoet/](https://github.com/square/javapoet/) * **License:** [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -4696,7 +4701,7 @@ This report was generated on **Thu Mar 16 14:18:38 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/google/j2objc/](https://github.com/google/j2objc/) * **License:** [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.1. +1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.2. * **Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) * **License:** [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) @@ -4889,6 +4894,7 @@ This report was generated on **Thu Mar 16 14:18:38 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -5254,12 +5260,12 @@ This report was generated on **Thu Mar 16 14:18:38 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:39 EET 2023** 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 Mar 17 11:30:19 EET 2023** 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.7.6` +# Dependencies of `io.spine.protodata:protodata-gradle-plugin:0.7.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.13.4.**No license information found** @@ -5370,7 +5376,7 @@ This report was generated on **Thu Mar 16 14:18:39 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -5601,10 +5607,6 @@ This report was generated on **Thu Mar 16 14:18:39 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/google/j2objc/](https://github.com/google/j2objc/) * **License:** [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.1. - * **Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) - * **License:** [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) - 1. **Group** : com.google.protobuf. **Name** : protobuf-gradle-plugin. **Version** : 0.9.2. * **Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) * **License:** [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) @@ -5798,6 +5800,7 @@ This report was generated on **Thu Mar 16 14:18:39 EET 2023** using [Gradle-Lice * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -6267,12 +6270,12 @@ This report was generated on **Thu Mar 16 14:18:39 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:40 EET 2023** 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 Mar 17 11:30:20 EET 2023** 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.7.6` +# Dependencies of `io.spine.protodata:protodata-protoc:0.7.7` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -7023,12 +7026,12 @@ This report was generated on **Thu Mar 16 14:18:40 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:41 EET 2023** 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 Mar 17 11:30:20 EET 2023** 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.7.6` +# Dependencies of `io.spine.protodata:protodata-test-env:0.7.7` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.13.4.**No license information found** @@ -7139,7 +7142,7 @@ This report was generated on **Thu Mar 16 14:18:41 EET 2023** using [Gradle-Lice * **Project URL:** [https://github.com/perfmark/perfmark](https://github.com/perfmark/perfmark) * **License:** [Apache 2.0](https://opensource.org/licenses/Apache-2.0) -1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : javax.annotation. **Name** : javax.annotation-api. **Version** : 1.3.2. * **Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **License:** [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) @@ -7548,6 +7551,7 @@ This report was generated on **Thu Mar 16 14:18:41 EET 2023** using [Gradle-Lice 1. **Group** : io.spine.validation. **Name** : spine-validation-java-bundle. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** 1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.80.**No license information found** +1. **Group** : io.spine.validation. **Name** : spine-validation-java-runtime. **Version** : 2.0.0-SNAPSHOT.81.**No license information found** 1. **Group** : jakarta.activation. **Name** : jakarta.activation-api. **Version** : 1.2.1. * **Project URL:** [https://www.eclipse.org](https://www.eclipse.org) * **License:** [EDL 1.0](http://www.eclipse.org/org/documents/edl-v10.php) @@ -7918,4 +7922,4 @@ This report was generated on **Thu Mar 16 14:18:41 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 16 14:18:42 EET 2023** 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 Mar 17 11:30:21 EET 2023** 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 698a6627e..3ff0ed5ea 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.7.6 +0.7.7 2015 @@ -98,7 +98,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-tool-base - 2.0.0-SNAPSHOT.156 + 2.0.0-SNAPSHOT.162 compile @@ -158,7 +158,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-plugin-testlib - 2.0.0-SNAPSHOT.156 + 2.0.0-SNAPSHOT.162 test @@ -246,7 +246,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-plugin-base - 2.0.0-SNAPSHOT.156 + 2.0.0-SNAPSHOT.162 io.spine.tools diff --git a/version.gradle.kts b/version.gradle.kts index f39708fc5..f3a530171 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -32,4 +32,5 @@ * * For dependencies on Spine SDK module please see [io.spine.internal.dependency.Spine]. */ -val protoDataVersion: String by extra("0.7.6") +val protoDataVersion: String by extra("0.7.7") +val toolBaseVersion: String by extra("2.0.0-SNAPSHOT.162") From 77a711d4920e8cb42f43fd21b4435edae4bff440 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 17 Mar 2023 11:42:15 +0200 Subject: [PATCH 04/46] Add doc --- .../kotlin/io/spine/protodata/event/CompilerEvent.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt index 4ec97174d..bce10ec6d 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt +++ b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvent.kt @@ -28,7 +28,19 @@ package io.spine.protodata.event import io.spine.base.EventMessage +/** + * A message of a Protobuf compiler event. + */ public interface CompilerEvent : EventMessage { + /** + * Shows if this event should result in code generation. + * + * If `false`, the event is purely informative and should not add any code generation tasks. + * Such events are emitted for the Proto definitions that come from a module's dependency. + * + * If `true`, the event describes a Proto definition that belongs to the currently analyzed + * module and thus may result in code generation. + */ public fun getGenerationRequested(): Boolean } From c551eb908d78f8393e59dc56772118f804e3bed8 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 17 Mar 2023 17:08:32 +0200 Subject: [PATCH 05/46] Add definitions for a dependency-based view --- api/src/main/proto/spine/protodata/events.proto | 9 +++++++++ api/src/main/proto/spine/protodata/source.proto | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/api/src/main/proto/spine/protodata/events.proto b/api/src/main/proto/spine/protodata/events.proto index f9010cd1e..6498511e0 100644 --- a/api/src/main/proto/spine/protodata/events.proto +++ b/api/src/main/proto/spine/protodata/events.proto @@ -37,6 +37,7 @@ option java_multiple_files = true; option (every_is).java_type = "CompilerEvent"; import "spine/protodata/ast.proto"; +import "spine/protodata/source.proto"; // Emitted when processing of a file begins. message FileEntered { @@ -313,3 +314,11 @@ message RpcExited { bool generation_requested = 4; } + +message DependencyDiscovered { + + FilePath file = 1; + + ProtobufSourceFile content = 2; + bool generation_requested = 3; // TODO:2023-03-17:dmytro.dashenkov: REMOVE. +} diff --git a/api/src/main/proto/spine/protodata/source.proto b/api/src/main/proto/spine/protodata/source.proto index 8d992ccd9..29634f369 100644 --- a/api/src/main/proto/spine/protodata/source.proto +++ b/api/src/main/proto/spine/protodata/source.proto @@ -42,7 +42,7 @@ import "spine/protodata/ast.proto"; // Includes all the message types declared in the file, along with their fields. // message ProtobufSourceFile { - option (entity).kind = PROJECTION; + option (entity).kind = VIEW; FilePath file_path = 1; @@ -73,3 +73,16 @@ message ProtobufSourceFile { // Shows if ProtoData renderers should generate code for this Protobuf definition. bool generation_requested = 6; } + +// A Protobuf definitions file which is included into the module as a dependency. +// +// Unlike `ProtobufSourceFile`, `ProtobufDependencyFile` should not result in any code generation. +// Rather, it serves an informative purpose. +// +message ProtobufDependencyFile { + option (entity).kind = VIEW; + + FilePath file_path = 1; + + ProtobufSourceFile content = 2; +} From 643ad581720a358ddb0de8ece65d9a40be162c80 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 17 Mar 2023 17:09:25 +0200 Subject: [PATCH 06/46] Implement a view collecting dependency file data --- .../spine/protodata/event/CompilerEvents.kt | 28 ++++++++++- .../io/spine/protodata/plugin/Plugin.kt | 2 +- .../io/spine/protodata/backend/Context.kt | 8 +--- .../spine/protodata/backend/DependencyView.kt | 48 +++++++++++++++++++ .../protodata/backend/ProtoSourceFileView.kt | 36 +++++--------- 5 files changed, 90 insertions(+), 32 deletions(-) create mode 100644 compiler/src/main/kotlin/io/spine/protodata/backend/DependencyView.kt diff --git a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt index bb3ab10fe..bdf485ed0 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt +++ b/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt @@ -31,6 +31,7 @@ import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest import io.spine.code.proto.FileSet import io.spine.protodata.Documentation import io.spine.protodata.File +import io.spine.protodata.ProtobufSourceFile import io.spine.protodata.path /** @@ -49,11 +50,34 @@ public object CompilerEvents { val filesToGenerate = request.fileToGenerateList.toSet() val files = FileSet.of(request.protoFileList) return sequence { - files.files() + val (ownFiles, dependencies) = files.files() + .partition { it.name in filesToGenerate } + dependencies + .map(::toDependencyEvent) + .forEach { yield(it) } + ownFiles .map { ProtoFileEvents(it, it.name in filesToGenerate) } .forEach { it.apply { produceFileEvents() } } } } + + private fun toDependencyEvent(fileDescriptor: FileDescriptor) = dependencyDiscovered { + val id = fileDescriptor.path() + file = id + content = fileDescriptor.toPbSourceFile() + } +} + +private fun FileDescriptor.toPbSourceFile(): ProtobufSourceFile { + val b = ProtobufSourceFile.newBuilder() + val id = path() + b.filePath = id + b.fileBuilder.path = id + b.fileBuilder.packageName = `package` + b.fileBuilder.syntax = syntax.toSyntaxVersion() + b.fileBuilder.addAllOption(listOptions(this.options)) + + return b.build() } /** @@ -61,7 +85,7 @@ public object CompilerEvents { */ private class ProtoFileEvents( private val fileDescriptor: FileDescriptor, - private val shouldGenerate: Boolean + private val shouldGenerate: Boolean = true ) { private val file = File.newBuilder() diff --git a/api/src/main/kotlin/io/spine/protodata/plugin/Plugin.kt b/api/src/main/kotlin/io/spine/protodata/plugin/Plugin.kt index 0d456ec44..04a75682d 100644 --- a/api/src/main/kotlin/io/spine/protodata/plugin/Plugin.kt +++ b/api/src/main/kotlin/io/spine/protodata/plugin/Plugin.kt @@ -68,7 +68,7 @@ public interface Plugin { */ public fun BoundedContextBuilder.apply(plugin: Plugin) { val repos = plugin.viewRepositories().toMutableList() - val defaultRepos = plugin.views().map { io.spine.protodata.plugin.ViewRepository.default(it) } + val defaultRepos = plugin.views().map { ViewRepository.default(it) } repos.addAll(defaultRepos) val repeatedView = repos.map { it.entityClass() } .groupingBy { it } diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/Context.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/Context.kt index 88ffb020b..2134a21cc 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/Context.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/Context.kt @@ -28,7 +28,6 @@ package io.spine.protodata.backend import io.spine.base.EventMessage import io.spine.core.userId -import io.spine.protodata.plugin.View import io.spine.protodata.plugin.ViewRepository import io.spine.server.BoundedContext.singleTenant import io.spine.server.BoundedContextBuilder @@ -44,13 +43,10 @@ public object CodeGenerationContext { */ @JvmStatic public fun builder(): BoundedContextBuilder = singleTenant("Code Generation").apply { - add(ViewRepository.default(builtinView())) + add(ViewRepository.default(ProtoSourceFileView::class.java)) + add(ViewRepository.default(DependencyView::class.java)) add(ConfigView.Repo()) } - - @Suppress("UNCHECKED_CAST") - private fun builtinView(): Class> = - ProtoSourceFileView::class.java as Class> } /** diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/DependencyView.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/DependencyView.kt new file mode 100644 index 000000000..7a17f7ab1 --- /dev/null +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/DependencyView.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2023, 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 + * + * http://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.backend + +import io.spine.core.External +import io.spine.core.Subscribe +import io.spine.protodata.FilePath +import io.spine.protodata.ProtobufDependencyFile +import io.spine.protodata.event.DependencyDiscovered +import io.spine.protodata.plugin.View +import io.spine.server.entity.alter + +/** + * A view of a dependency Proto file. + */ +internal class DependencyView : + View() { + + @Subscribe + internal fun on(@External e: DependencyDiscovered) = alter { + filePath = e.file + content = e.content + } +} diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt index 407940cd9..7e22c332f 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/ProtoSourceFileView.kt @@ -58,7 +58,7 @@ import io.spine.protodata.event.TypeOptionDiscovered import io.spine.protodata.isPartOfOneof import io.spine.protodata.plugin.View import io.spine.protodata.typeUrl -import io.spine.server.entity.update +import io.spine.server.entity.alter /** * A view which collects information about a Protobuf source file. @@ -67,26 +67,20 @@ internal class ProtoSourceFileView : View() { @Subscribe - internal fun on(@External e: FileEntered) { - update { - filePath = e.file.path - file = e.file - generationRequested = e.generationRequested - } + internal fun on(@External e: FileEntered) = alter { + filePath = e.file.path + file = e.file + generationRequested = e.generationRequested } @Subscribe - internal fun on(@External e: FileOptionDiscovered) { - update { - fileBuilder.addOption(e.option) - } + internal fun on(@External e: FileOptionDiscovered) = alter { + fileBuilder.addOption(e.option) } @Subscribe - internal fun on(@External e: TypeEntered) { - update { - putType(e.type.typeUrl(), e.type) - } + internal fun on(@External e: TypeEntered) = alter { + putType(e.type.typeUrl(), e.type) } @Subscribe @@ -122,10 +116,8 @@ internal class ProtoSourceFileView } @Subscribe - internal fun on(@External e: EnumEntered) { - update { - putEnumType(e.type.typeUrl(), e.type) - } + internal fun on(@External e: EnumEntered) = alter { + putEnumType(e.type.typeUrl(), e.type) } @Subscribe @@ -145,10 +137,8 @@ internal class ProtoSourceFileView } @Subscribe - internal fun on(@External e: ServiceEntered) { - update { - putService(e.service.typeUrl(), e.service) - } + internal fun on(@External e: ServiceEntered) = alter{ + putService(e.service.typeUrl(), e.service) } @Subscribe From b5963fdd38f3dc79e3a4a538b9993055c7a21d5a Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 20 Mar 2023 13:11:18 +0200 Subject: [PATCH 07/46] Move some implementation details to `:compiler` --- .../io/spine/protodata/AstExtensions.kt | 6 +- .../protodata/backend}/CompilerEvents.kt | 47 ++++------ .../spine/protodata/backend}/Documentation.kt | 89 +++++++++---------- .../protodata/backend}/EnumCompilerEvents.kt | 12 ++- .../backend}/MessageCompilerEvents.kt | 15 +++- .../backend}/OptionsCompilerEvents.kt | 5 +- .../io/spine/protodata/backend/Pipeline.kt | 1 - .../backend}/ServiceCompilerEvents.kt | 12 ++- .../protodata/backend}/TypeExtensions.kt | 4 +- .../backend/CodeGenerationContextSpec.kt | 3 +- .../protodata/backend}/CompilerEventsSpec.kt | 42 ++++++--- license-report.md | 18 ++-- 12 files changed, 139 insertions(+), 115 deletions(-) rename {api/src/main/kotlin/io/spine/protodata/event => compiler/src/main/kotlin/io/spine/protodata/backend}/CompilerEvents.kt (79%) rename {api/src/main/kotlin/io/spine/protodata => compiler/src/main/kotlin/io/spine/protodata/backend}/Documentation.kt (67%) rename {api/src/main/kotlin/io/spine/protodata/event => compiler/src/main/kotlin/io/spine/protodata/backend}/EnumCompilerEvents.kt (91%) rename {api/src/main/kotlin/io/spine/protodata/event => compiler/src/main/kotlin/io/spine/protodata/backend}/MessageCompilerEvents.kt (93%) rename {api/src/main/kotlin/io/spine/protodata/event => compiler/src/main/kotlin/io/spine/protodata/backend}/OptionsCompilerEvents.kt (96%) rename {api/src/main/kotlin/io/spine/protodata/event => compiler/src/main/kotlin/io/spine/protodata/backend}/ServiceCompilerEvents.kt (91%) rename {api/src/main/kotlin/io/spine/protodata/event => compiler/src/main/kotlin/io/spine/protodata/backend}/TypeExtensions.kt (98%) rename {api/src/test/kotlin/io/spine/protodata/event => compiler/src/test/kotlin/io/spine/protodata/backend}/CompilerEventsSpec.kt (84%) diff --git a/api/src/main/kotlin/io/spine/protodata/AstExtensions.kt b/api/src/main/kotlin/io/spine/protodata/AstExtensions.kt index 32d1b6de7..2e9a2efa4 100644 --- a/api/src/main/kotlin/io/spine/protodata/AstExtensions.kt +++ b/api/src/main/kotlin/io/spine/protodata/AstExtensions.kt @@ -195,12 +195,12 @@ private val FileDescriptor.typeUrlPrefix: String /** * Obtains the name of this `oneof` as a [OneofName]. */ -internal fun OneofDescriptor.name(): OneofName = oneofName { value = name } +public fun OneofDescriptor.name(): OneofName = oneofName { value = name } /** * Obtains the name of this field as a [FieldName]. */ -internal fun FieldDescriptor.name(): FieldName = fieldName { value = name } +public fun FieldDescriptor.name(): FieldName = fieldName { value = name } /** * Obtains the relative path to this file as a [FilePath]. @@ -219,7 +219,7 @@ public fun ServiceDescriptor.name(): ServiceName = serviceName { /** * Obtains the name of this RPC method as an [RpcName]. */ -internal fun MethodDescriptor.name(): RpcName = rpcName { value = name } +public fun MethodDescriptor.name(): RpcName = rpcName { value = name } /** * Obtains a [Type] wrapping this `PrimitiveType`. diff --git a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/CompilerEvents.kt similarity index 79% rename from api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt rename to compiler/src/main/kotlin/io/spine/protodata/backend/CompilerEvents.kt index bdf485ed0..18607cc08 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/CompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/CompilerEvents.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,14 +24,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata.event +package io.spine.protodata.backend -import com.google.protobuf.Descriptors.FileDescriptor -import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest +import com.google.protobuf.Descriptors +import com.google.protobuf.compiler.PluginProtos import io.spine.code.proto.FileSet -import io.spine.protodata.Documentation import io.spine.protodata.File -import io.spine.protodata.ProtobufSourceFile +import io.spine.protodata.event.CompilerEvent +import io.spine.protodata.event.FileEntered +import io.spine.protodata.event.FileExited +import io.spine.protodata.event.FileOptionDiscovered import io.spine.protodata.path /** @@ -46,45 +48,34 @@ public object CompilerEvents { * * The resulting sequence is always finite, it's limited by the type set. */ - public fun parse(request: CodeGeneratorRequest): Sequence { + public fun parse(request: PluginProtos.CodeGeneratorRequest): Sequence { val filesToGenerate = request.fileToGenerateList.toSet() val files = FileSet.of(request.protoFileList) return sequence { val (ownFiles, dependencies) = files.files() .partition { it.name in filesToGenerate } - dependencies - .map(::toDependencyEvent) - .forEach { yield(it) } +// dependencies +// .map(::toDependencyEvent) +// .forEach { yield(it) } ownFiles .map { ProtoFileEvents(it, it.name in filesToGenerate) } .forEach { it.apply { produceFileEvents() } } } } - private fun toDependencyEvent(fileDescriptor: FileDescriptor) = dependencyDiscovered { - val id = fileDescriptor.path() - file = id - content = fileDescriptor.toPbSourceFile() - } -} - -private fun FileDescriptor.toPbSourceFile(): ProtobufSourceFile { - val b = ProtobufSourceFile.newBuilder() - val id = path() - b.filePath = id - b.fileBuilder.path = id - b.fileBuilder.packageName = `package` - b.fileBuilder.syntax = syntax.toSyntaxVersion() - b.fileBuilder.addAllOption(listOptions(this.options)) - - return b.build() +// private fun toDependencyEvent(fileDescriptor: Descriptors.FileDescriptor) = +// dependencyDiscovered { +// val id = fileDescriptor.path() +// file = id +// content = fileDescriptor.toPbSourceFile() +// } } /** * Produces events from the associated file. */ private class ProtoFileEvents( - private val fileDescriptor: FileDescriptor, + private val fileDescriptor: Descriptors.FileDescriptor, private val shouldGenerate: Boolean = true ) { diff --git a/api/src/main/kotlin/io/spine/protodata/Documentation.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/Documentation.kt similarity index 67% rename from api/src/main/kotlin/io/spine/protodata/Documentation.kt rename to compiler/src/main/kotlin/io/spine/protodata/backend/Documentation.kt index a8e07db4e..d58382877 100644 --- a/api/src/main/kotlin/io/spine/protodata/Documentation.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/Documentation.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,20 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata - -import com.google.protobuf.DescriptorProtos.DescriptorProto -import com.google.protobuf.DescriptorProtos.EnumDescriptorProto -import com.google.protobuf.DescriptorProtos.FileDescriptorProto -import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto -import com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location -import com.google.protobuf.Descriptors.Descriptor -import com.google.protobuf.Descriptors.EnumDescriptor -import com.google.protobuf.Descriptors.EnumValueDescriptor -import com.google.protobuf.Descriptors.FieldDescriptor -import com.google.protobuf.Descriptors.MethodDescriptor -import com.google.protobuf.Descriptors.OneofDescriptor -import com.google.protobuf.Descriptors.ServiceDescriptor +package io.spine.protodata.backend + +import com.google.protobuf.DescriptorProtos +import com.google.protobuf.Descriptors +import io.spine.protodata.Doc import io.spine.string.trimWhitespace import io.spine.util.interlaced @@ -45,16 +36,16 @@ import io.spine.util.interlaced * Documentation contained in a Protobuf file. */ internal class Documentation( - locations: List + locations: List ) { - private val docs: Map = - locations.associateBy(LocationPath::from) + private val docs: Map = + locations.associateBy(LocationPath.Companion::from) /** * Obtains documentation for the given message. */ - fun forMessage(descriptor: Descriptor): Doc { + fun forMessage(descriptor: Descriptors.Descriptor): Doc { val path = LocationPath.fromMessage(descriptor) return commentsAt(path) } @@ -62,7 +53,7 @@ internal class Documentation( /** * Obtains documentation for the given message field. */ - fun forField(descriptor: FieldDescriptor): Doc { + fun forField(descriptor: Descriptors.FieldDescriptor): Doc { val path = LocationPath.fromMessage(descriptor.containingType) .field(descriptor) return commentsAt(path) @@ -71,7 +62,7 @@ internal class Documentation( /** * Obtains documentation for the given `oneof` group. */ - fun forOneof(descriptor: OneofDescriptor): Doc { + fun forOneof(descriptor: Descriptors.OneofDescriptor): Doc { val path = LocationPath.fromMessage(descriptor.containingType) .oneof(descriptor) return commentsAt(path) @@ -80,7 +71,7 @@ internal class Documentation( /** * Obtains documentation for the given enum type. */ - fun forEnum(descriptor: EnumDescriptor): Doc { + fun forEnum(descriptor: Descriptors.EnumDescriptor): Doc { val path = LocationPath.fromEnum(descriptor) return commentsAt(path) } @@ -88,7 +79,7 @@ internal class Documentation( /** * Obtains documentation for the given enum constant. */ - fun forEnumConstant(descriptor: EnumValueDescriptor): Doc { + fun forEnumConstant(descriptor: Descriptors.EnumValueDescriptor): Doc { val path = LocationPath.fromEnum(descriptor.type) .constant(descriptor) return commentsAt(path) @@ -97,7 +88,7 @@ internal class Documentation( /** * Obtains documentation for the given service. */ - fun forService(descriptor: ServiceDescriptor): Doc { + fun forService(descriptor: Descriptors.ServiceDescriptor): Doc { val path = LocationPath.fromService(descriptor) return commentsAt(path) } @@ -105,14 +96,14 @@ internal class Documentation( /** * Obtains documentation for the given RPC method. */ - fun forRpc(descriptor: MethodDescriptor): Doc { + fun forRpc(descriptor: Descriptors.MethodDescriptor): Doc { val path = LocationPath.fromService(descriptor.service) .rpc(descriptor) return commentsAt(path) } private fun commentsAt(path: LocationPath): Doc { - val location = docs[path] ?: Location.getDefaultInstance() + val location = docs[path] ?: DescriptorProtos.SourceCodeInfo.Location.getDefaultInstance() return Doc.newBuilder() .setLeadingComment(location.leadingComments.trimWhitespace()) .setTrailingComment(location.trailingComments.trimWhitespace()) @@ -140,19 +131,19 @@ private constructor(private val value: List) { /** * Obtains the `LocationPath` from the Protobuf's `Location`. */ - fun from(location: Location): LocationPath { + fun from(location: DescriptorProtos.SourceCodeInfo.Location): LocationPath { return LocationPath(location.pathList) } /** * Obtains the `LocationPath` from the given message. */ - fun fromMessage(descriptor: Descriptor): LocationPath { + fun fromMessage(descriptor: Descriptors.Descriptor): LocationPath { val numbers = mutableListOf() - numbers.add(FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER) + numbers.add(DescriptorProtos.FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER) if (!descriptor.topLevel) { numbers.addAll(upToTop(descriptor.containingType)) - numbers.add(DescriptorProto.NESTED_TYPE_FIELD_NUMBER) + numbers.add(DescriptorProtos.DescriptorProto.NESTED_TYPE_FIELD_NUMBER) } numbers.add(descriptor.index) return LocationPath(numbers) @@ -161,14 +152,14 @@ private constructor(private val value: List) { /** * Obtains the `LocationPath` from the given enum. */ - fun fromEnum(descriptor: EnumDescriptor): LocationPath { + fun fromEnum(descriptor: Descriptors.EnumDescriptor): LocationPath { val numbers = mutableListOf() if (descriptor.topLevel) { - numbers.add(FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER) + numbers.add(DescriptorProtos.FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER) } else { - numbers.add(FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER) + numbers.add(DescriptorProtos.FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER) numbers.addAll(upToTop(descriptor.containingType)) - numbers.add(DescriptorProto.ENUM_TYPE_FIELD_NUMBER) + numbers.add(DescriptorProtos.DescriptorProto.ENUM_TYPE_FIELD_NUMBER) } numbers.add(descriptor.index) return LocationPath(numbers) @@ -177,21 +168,21 @@ private constructor(private val value: List) { /** * Obtains the `LocationPath` from the given service. */ - fun fromService(descriptor: ServiceDescriptor): LocationPath { + fun fromService(descriptor: Descriptors.ServiceDescriptor): LocationPath { return LocationPath(listOf( - FileDescriptorProto.SERVICE_FIELD_NUMBER, + DescriptorProtos.FileDescriptorProto.SERVICE_FIELD_NUMBER, descriptor.index )) } - private fun upToTop(parent: Descriptor): List { + private fun upToTop(parent: Descriptors.Descriptor): List { val rootPath = mutableListOf() - var containingType: Descriptor? = parent + var containingType: Descriptors.Descriptor? = parent while (containingType != null) { rootPath.add(containingType.index) containingType = containingType.containingType } - return rootPath.interlaced(DescriptorProto.NESTED_TYPE_FIELD_NUMBER) + return rootPath.interlaced(DescriptorProtos.DescriptorProto.NESTED_TYPE_FIELD_NUMBER) .toList() .reversed() } @@ -202,32 +193,32 @@ private constructor(private val value: List) { * * It's expected that the field belongs to the message located at this location path. */ - fun field(field: FieldDescriptor): LocationPath = - subDeclaration(DescriptorProto.FIELD_FIELD_NUMBER, field.index) + fun field(field: Descriptors.FieldDescriptor): LocationPath = + subDeclaration(DescriptorProtos.DescriptorProto.FIELD_FIELD_NUMBER, field.index) /** * Obtains the `LocationPath` to the given `oneof` group. * * It's expected that the group is declared in the message located at this location path. */ - fun oneof(group: OneofDescriptor): LocationPath = - subDeclaration(DescriptorProto.ONEOF_DECL_FIELD_NUMBER, group.index) + fun oneof(group: Descriptors.OneofDescriptor): LocationPath = + subDeclaration(DescriptorProtos.DescriptorProto.ONEOF_DECL_FIELD_NUMBER, group.index) /** * Obtains the `LocationPath` to the given enum constant. * * It's expected that the constant belongs to the enum located at this location path. */ - fun constant(constant: EnumValueDescriptor): LocationPath = - subDeclaration(EnumDescriptorProto.VALUE_FIELD_NUMBER, constant.index) + fun constant(constant: Descriptors.EnumValueDescriptor): LocationPath = + subDeclaration(DescriptorProtos.EnumDescriptorProto.VALUE_FIELD_NUMBER, constant.index) /** * Obtains the `LocationPath` to the given RPC. * * It's expected that the RPC belongs to the service located at this location path. */ - fun rpc(rpc: MethodDescriptor): LocationPath = - subDeclaration(ServiceDescriptorProto.METHOD_FIELD_NUMBER, rpc.index) + fun rpc(rpc: Descriptors.MethodDescriptor): LocationPath = + subDeclaration(DescriptorProtos.ServiceDescriptorProto.METHOD_FIELD_NUMBER, rpc.index) override fun toString(): String { return "LocationPath(${value.joinToString()})" @@ -237,8 +228,8 @@ private constructor(private val value: List) { LocationPath(value + arrayOf(descriptorFieldNumber, index)) } -private val Descriptor.topLevel: Boolean +private val Descriptors.Descriptor.topLevel: Boolean get() = containingType == null -private val EnumDescriptor.topLevel: Boolean +private val Descriptors.EnumDescriptor.topLevel: Boolean get() = containingType == null diff --git a/api/src/main/kotlin/io/spine/protodata/event/EnumCompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/EnumCompilerEvents.kt similarity index 91% rename from api/src/main/kotlin/io/spine/protodata/event/EnumCompilerEvents.kt rename to compiler/src/main/kotlin/io/spine/protodata/backend/EnumCompilerEvents.kt index 0ec30f8e8..ebc463ee7 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/EnumCompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/EnumCompilerEvents.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,15 +24,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata.event +package io.spine.protodata.backend import com.google.protobuf.Descriptors import io.spine.protodata.ConstantName -import io.spine.protodata.Documentation import io.spine.protodata.EnumConstant import io.spine.protodata.EnumType import io.spine.protodata.File import io.spine.protodata.TypeName +import io.spine.protodata.event.CompilerEvent +import io.spine.protodata.event.EnumConstantEntered +import io.spine.protodata.event.EnumConstantExited +import io.spine.protodata.event.EnumConstantOptionDiscovered +import io.spine.protodata.event.EnumEntered +import io.spine.protodata.event.EnumExited +import io.spine.protodata.event.EnumOptionDiscovered import io.spine.protodata.name /** diff --git a/api/src/main/kotlin/io/spine/protodata/event/MessageCompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/MessageCompilerEvents.kt similarity index 93% rename from api/src/main/kotlin/io/spine/protodata/event/MessageCompilerEvents.kt rename to compiler/src/main/kotlin/io/spine/protodata/backend/MessageCompilerEvents.kt index f9a58d5be..7b892fa8b 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/MessageCompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/MessageCompilerEvents.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,16 +24,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata.event +package io.spine.protodata.backend import com.google.protobuf.Descriptors import com.google.protobuf.Empty -import io.spine.protodata.Documentation import io.spine.protodata.Field import io.spine.protodata.File import io.spine.protodata.MessageType import io.spine.protodata.OneofGroup import io.spine.protodata.TypeName +import io.spine.protodata.event.CompilerEvent +import io.spine.protodata.event.FieldEntered +import io.spine.protodata.event.FieldExited +import io.spine.protodata.event.FieldOptionDiscovered +import io.spine.protodata.event.OneofGroupEntered +import io.spine.protodata.event.OneofGroupExited +import io.spine.protodata.event.OneofOptionDiscovered +import io.spine.protodata.event.TypeEntered +import io.spine.protodata.event.TypeExited +import io.spine.protodata.event.TypeOptionDiscovered import io.spine.protodata.name /** diff --git a/api/src/main/kotlin/io/spine/protodata/event/OptionsCompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/OptionsCompilerEvents.kt similarity index 96% rename from api/src/main/kotlin/io/spine/protodata/event/OptionsCompilerEvents.kt rename to compiler/src/main/kotlin/io/spine/protodata/backend/OptionsCompilerEvents.kt index 634478b9a..b1acfda23 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/OptionsCompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/OptionsCompilerEvents.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata.event +package io.spine.protodata.backend import com.google.protobuf.Descriptors.EnumValueDescriptor import com.google.protobuf.Descriptors.FieldDescriptor @@ -34,6 +34,7 @@ import com.google.protobuf.GeneratedMessageV3 import io.spine.protobuf.AnyPacker import io.spine.protobuf.TypeConverter import io.spine.protodata.Option +import io.spine.protodata.event.CompilerEvent /** * Yields events regarding a set of options. diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/Pipeline.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/Pipeline.kt index ad4e165c5..9e017f7f0 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/Pipeline.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/Pipeline.kt @@ -31,7 +31,6 @@ import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest import io.spine.annotation.Internal import io.spine.environment.DefaultMode import io.spine.protodata.config.Configuration -import io.spine.protodata.event.CompilerEvents import io.spine.protodata.plugin.Plugin import io.spine.protodata.plugin.apply import io.spine.protodata.renderer.Renderer diff --git a/api/src/main/kotlin/io/spine/protodata/event/ServiceCompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/ServiceCompilerEvents.kt similarity index 91% rename from api/src/main/kotlin/io/spine/protodata/event/ServiceCompilerEvents.kt rename to compiler/src/main/kotlin/io/spine/protodata/backend/ServiceCompilerEvents.kt index 39ff247e4..656f5fc5d 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/ServiceCompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/ServiceCompilerEvents.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,15 +24,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata.event +package io.spine.protodata.backend import com.google.protobuf.Descriptors -import io.spine.protodata.Documentation import io.spine.protodata.File import io.spine.protodata.Rpc import io.spine.protodata.Service import io.spine.protodata.ServiceName import io.spine.protodata.cardinality +import io.spine.protodata.event.CompilerEvent +import io.spine.protodata.event.RpcEntered +import io.spine.protodata.event.RpcExited +import io.spine.protodata.event.RpcOptionDiscovered +import io.spine.protodata.event.ServiceEntered +import io.spine.protodata.event.ServiceExited +import io.spine.protodata.event.ServiceOptionDiscovered import io.spine.protodata.name /** diff --git a/api/src/main/kotlin/io/spine/protodata/event/TypeExtensions.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/TypeExtensions.kt similarity index 98% rename from api/src/main/kotlin/io/spine/protodata/event/TypeExtensions.kt rename to compiler/src/main/kotlin/io/spine/protodata/backend/TypeExtensions.kt index 2a8ef5911..348992c40 100644 --- a/api/src/main/kotlin/io/spine/protodata/event/TypeExtensions.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/TypeExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata.event +package io.spine.protodata.backend import com.google.protobuf.Descriptors.FieldDescriptor import com.google.protobuf.Descriptors.FieldDescriptor.Type.BOOL diff --git a/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt b/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt index 685f18814..4bfd017d4 100644 --- a/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt +++ b/compiler/src/test/kotlin/io/spine/protodata/backend/CodeGenerationContextSpec.kt @@ -36,13 +36,13 @@ import io.spine.protodata.Option import io.spine.protodata.PrimitiveType.TYPE_BOOL import io.spine.protodata.ProtobufSourceFile import io.spine.protodata.asType -import io.spine.protodata.event.CompilerEvents import io.spine.protodata.path import io.spine.protodata.test.DoctorProto import io.spine.protodata.typeUrl import io.spine.testing.server.blackbox.BlackBox import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test @@ -109,6 +109,7 @@ class CodeGenerationContextSpec { .hasSize(2) } + @Disabled @Test fun dependencies() { val assertSourceFile = ctx.assertEntity( diff --git a/api/src/test/kotlin/io/spine/protodata/event/CompilerEventsSpec.kt b/compiler/src/test/kotlin/io/spine/protodata/backend/CompilerEventsSpec.kt similarity index 84% rename from api/src/test/kotlin/io/spine/protodata/event/CompilerEventsSpec.kt rename to compiler/src/test/kotlin/io/spine/protodata/backend/CompilerEventsSpec.kt index adf3ab6b0..4aca9c698 100644 --- a/api/src/test/kotlin/io/spine/protodata/event/CompilerEventsSpec.kt +++ b/compiler/src/test/kotlin/io/spine/protodata/backend/CompilerEventsSpec.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2023, 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. @@ -24,13 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.protodata.event +package io.spine.protodata.backend -import com.google.common.truth.Truth.assertThat -import com.google.common.truth.extensions.proto.ProtoTruth.assertThat +import com.google.common.truth.Truth +import com.google.common.truth.extensions.proto.ProtoTruth import com.google.protobuf.BoolValue import com.google.protobuf.DescriptorProtos -import com.google.protobuf.DescriptorProtos.MethodOptions.IdempotencyLevel import com.google.protobuf.Message import com.google.protobuf.StringValue import com.google.protobuf.compiler.codeGeneratorRequest @@ -40,6 +39,26 @@ import io.kotest.matchers.shouldNotBe import io.spine.base.EventMessage import io.spine.option.OptionsProto import io.spine.protobuf.unpackGuessingType +import io.spine.protodata.event.CompilerEvent +import io.spine.protodata.event.EnumConstantEntered +import io.spine.protodata.event.EnumConstantExited +import io.spine.protodata.event.EnumEntered +import io.spine.protodata.event.EnumExited +import io.spine.protodata.event.FieldEntered +import io.spine.protodata.event.FieldExited +import io.spine.protodata.event.FieldOptionDiscovered +import io.spine.protodata.event.FileEntered +import io.spine.protodata.event.FileExited +import io.spine.protodata.event.FileOptionDiscovered +import io.spine.protodata.event.OneofGroupEntered +import io.spine.protodata.event.OneofGroupExited +import io.spine.protodata.event.RpcEntered +import io.spine.protodata.event.RpcExited +import io.spine.protodata.event.RpcOptionDiscovered +import io.spine.protodata.event.ServiceEntered +import io.spine.protodata.event.ServiceExited +import io.spine.protodata.event.TypeEntered +import io.spine.protodata.event.TypeExited import io.spine.protodata.messageType import io.spine.protodata.test.DoctorProto import io.spine.protodata.typeName @@ -183,22 +202,22 @@ class CompilerEventsSpec { event.option.name shouldBe "idempotency_level" event.option.value.unpackGuessingType() shouldBe enumValue { - name = IdempotencyLevel.NO_SIDE_EFFECTS.name - number = IdempotencyLevel.NO_SIDE_EFFECTS_VALUE + name = DescriptorProtos.MethodOptions.IdempotencyLevel.NO_SIDE_EFFECTS.name + number = DescriptorProtos.MethodOptions.IdempotencyLevel.NO_SIDE_EFFECTS_VALUE } } @Test fun `include message doc info`() { val typeEntered = emitted() - assertThat(typeEntered.type) + ProtoTruth.assertThat(typeEntered.type) .comparingExpectedFieldsOnly() .isEqualTo(messageType { name = typeName { simpleName = "Journey" } }) val doc = typeEntered.type.doc - assertThat(doc.leadingComment.split(nl)) + Truth.assertThat(doc.leadingComment.split(nl)) .containsExactly( "A Doctor's journey.", "", @@ -209,7 +228,7 @@ class CompilerEventsSpec { doc.trailingComment shouldBe "Impl note: test type." doc.detachedCommentList[0] shouldBe "Detached 1." - assertThat(doc.detachedCommentList[1].split(nl)) + Truth.assertThat(doc.detachedCommentList[1].split(nl)) .containsExactly( "Detached 2.", "Indentation is not preserved in Protobuf.", @@ -231,7 +250,7 @@ class CompilerEventsSpec { private fun assertEmits(vararg types: KClass) { val javaClasses = types.map { it.java } - assertThat(events) + ProtoTruth.assertThat(events) .comparingElementsUsing(Correspondences.type()) .containsAtLeastElementsIn(javaClasses) .inOrder() @@ -243,6 +262,7 @@ class CompilerEventsSpec { } } + /** * Obtains the option of the given type [T] from this [FileOptionDiscovered] event. * diff --git a/license-report.md b/license-report.md index 205e00cff..3f95d4947 100644 --- a/license-report.md +++ b/license-report.md @@ -897,7 +897,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:14 EET 2023** 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 Mar 20 12:59:45 EET 2023** 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). @@ -1802,7 +1802,7 @@ This report was generated on **Fri Mar 17 11:30:14 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:15 EET 2023** 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 Mar 20 12:59:47 EET 2023** 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). @@ -2684,7 +2684,7 @@ This report was generated on **Fri Mar 17 11:30:15 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:16 EET 2023** 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 Mar 20 12:59:48 EET 2023** 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). @@ -3568,7 +3568,7 @@ This report was generated on **Fri Mar 17 11:30:16 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:17 EET 2023** 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 Mar 20 12:59:49 EET 2023** 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). @@ -4469,7 +4469,7 @@ This report was generated on **Fri Mar 17 11:30:17 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:18 EET 2023** 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 Mar 20 12:59:50 EET 2023** 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). @@ -5260,7 +5260,7 @@ This report was generated on **Fri Mar 17 11:30:18 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:19 EET 2023** 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 Mar 20 12:59:52 EET 2023** 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). @@ -6270,7 +6270,7 @@ This report was generated on **Fri Mar 17 11:30:19 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:20 EET 2023** 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 Mar 20 12:59:53 EET 2023** 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). @@ -7026,7 +7026,7 @@ This report was generated on **Fri Mar 17 11:30:20 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:20 EET 2023** 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 Mar 20 12:59:54 EET 2023** 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). @@ -7922,4 +7922,4 @@ This report was generated on **Fri Mar 17 11:30:20 EET 2023** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Mar 17 11:30:21 EET 2023** 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 Mar 20 12:59:55 EET 2023** 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 From f8ca578dc82f938793962b8e7d848922d6a96588 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Wed, 22 Mar 2023 16:26:14 +0200 Subject: [PATCH 08/46] Emit events for dependencies --- .../main/proto/spine/protodata/source.proto | 3 - .../spine/protodata/backend/AstComponents.kt | 138 +++++++++++++++ .../spine/protodata/backend/CompilerEvents.kt | 161 ++++++++++++++++-- .../spine/protodata/backend/Documentation.kt | 6 + .../protodata/backend/EnumCompilerEvents.kt | 9 +- .../backend/MessageCompilerEvents.kt | 37 +--- .../backend/OptionsCompilerEvents.kt | 28 ++- .../protodata/backend/ProtoSourceFileView.kt | 1 - .../backend/ServiceCompilerEvents.kt | 17 +- 9 files changed, 311 insertions(+), 89 deletions(-) create mode 100644 compiler/src/main/kotlin/io/spine/protodata/backend/AstComponents.kt diff --git a/api/src/main/proto/spine/protodata/source.proto b/api/src/main/proto/spine/protodata/source.proto index 29634f369..0889f69d1 100644 --- a/api/src/main/proto/spine/protodata/source.proto +++ b/api/src/main/proto/spine/protodata/source.proto @@ -69,9 +69,6 @@ message ProtobufSourceFile { // The keys are the type URLs of the services. // map service = 5; - - // Shows if ProtoData renderers should generate code for this Protobuf definition. - bool generation_requested = 6; } // A Protobuf definitions file which is included into the module as a dependency. diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/AstComponents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/AstComponents.kt new file mode 100644 index 000000000..d3b97f785 --- /dev/null +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/AstComponents.kt @@ -0,0 +1,138 @@ +/* + * Copyright 2023, 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 + * + * http://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.backend + +import com.google.protobuf.Descriptors +import com.google.protobuf.Empty +import io.spine.protodata.EnumConstant +import io.spine.protodata.Field +import io.spine.protodata.Rpc +import io.spine.protodata.ServiceName +import io.spine.protodata.TypeName +import io.spine.protodata.cardinality +import io.spine.protodata.constantName +import io.spine.protodata.name + +internal fun Descriptors.FieldDescriptor.buildFieldWithOptions( + declaringType: TypeName, + documentation: Documentation +): Field { + val field = buildField(declaringType, documentation) + return field.toBuilder() + .addAllOption(listOptions(options)) + .build() +} + +internal fun Descriptors.FieldDescriptor.buildField( + declaringType: TypeName, + documentation: Documentation +): Field { + return Field.newBuilder() + .setName(name()) + .setDeclaringType(declaringType) + .setNumber(number) + .setOrderOfDeclaration(index) + .assignTypeAndCardinality(this) + .setDoc(documentation.forField(this)) + .build() +} + +/** + * Assigns the field type and cardinality (`map`/`list`/`oneof_name`/`single`) to the receiver + * builder. + * + * @return the receiver for method chaining. + */ +private fun Field.Builder.assignTypeAndCardinality( + desc: Descriptors.FieldDescriptor +): Field.Builder { + if (desc.isMapField) { + val (keyField, valueField) = desc.messageType.fields + map = Field.OfMap.newBuilder() + .setKeyType(keyField.primitiveType()) + .build() + type = valueField.type() + } else { + type = desc.type() + when { + desc.isRepeated -> list = Empty.getDefaultInstance() + desc.realContainingOneof != null -> oneofName = desc.realContainingOneof.name() + else -> single = Empty.getDefaultInstance() + } + } + return this +} + +internal fun Descriptors.EnumValueDescriptor.buildConstantWithOptions( + declaringType: TypeName, + documentation: Documentation +): EnumConstant { + val constant = buildConstant(declaringType, documentation) + return constant.toBuilder() + .addAllOption(listOptions(options)) + .build() +} + +internal fun Descriptors.EnumValueDescriptor.buildConstant( + declaringType: TypeName, + documentation: Documentation +): EnumConstant { + return EnumConstant.newBuilder() + .setName(constantName { value = name }) + .setDeclaredIn(declaringType) + .setNumber(number) + .setOrderOfDeclaration(index) + .setDoc(documentation.forEnumConstant(this)) + .build() +} + +internal fun Descriptors.MethodDescriptor.buildRpcWithOptions( + declaringService: ServiceName, + documentation: Documentation +) : Rpc { + return buildRpc(declaringService, documentation) + .toBuilder() + .addAllOption(listOptions(options)) + .build() +} + +internal fun Descriptors.MethodDescriptor.buildRpc( + declaringService: ServiceName, + documentation: Documentation +) : Rpc { + val name = name() + val cardinality = cardinality() + return Rpc.newBuilder() + .setName(name) + .setCardinality(cardinality) + .setRequestType(inputType.name()) + .setResponseType(outputType.name()) + .setDoc(documentation.forRpc(this)) + .setService(declaringService) + .build() +} + diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/CompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/CompilerEvents.kt index 18607cc08..c039cbd37 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/CompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/CompilerEvents.kt @@ -29,12 +29,24 @@ package io.spine.protodata.backend import com.google.protobuf.Descriptors import com.google.protobuf.compiler.PluginProtos import io.spine.code.proto.FileSet -import io.spine.protodata.File +import io.spine.protodata.EnumType +import io.spine.protodata.FilePath +import io.spine.protodata.MessageType +import io.spine.protodata.ProtobufSourceFile +import io.spine.protodata.Service +import io.spine.protodata.enumType import io.spine.protodata.event.CompilerEvent import io.spine.protodata.event.FileEntered import io.spine.protodata.event.FileExited import io.spine.protodata.event.FileOptionDiscovered +import io.spine.protodata.event.dependencyDiscovered +import io.spine.protodata.file +import io.spine.protodata.messageType +import io.spine.protodata.name +import io.spine.protodata.oneofGroup import io.spine.protodata.path +import io.spine.protodata.service +import io.spine.protodata.typeUrl /** * A factory for Protobuf compiler events. @@ -54,21 +66,140 @@ public object CompilerEvents { return sequence { val (ownFiles, dependencies) = files.files() .partition { it.name in filesToGenerate } -// dependencies -// .map(::toDependencyEvent) -// .forEach { yield(it) } + yieldAll(dependencies.map(::toDependencyEvent)) ownFiles .map { ProtoFileEvents(it, it.name in filesToGenerate) } .forEach { it.apply { produceFileEvents() } } } } -// private fun toDependencyEvent(fileDescriptor: Descriptors.FileDescriptor) = -// dependencyDiscovered { -// val id = fileDescriptor.path() -// file = id -// content = fileDescriptor.toPbSourceFile() -// } + private fun toDependencyEvent(fileDescriptor: Descriptors.FileDescriptor) = + dependencyDiscovered { + val id = fileDescriptor.path() + file = id + content = fileDescriptor.toPbSourceFile() + } +} + +private fun Descriptors.FileDescriptor.toPbSourceFile(): ProtobufSourceFile { + val path = path() + val result = ProtobufSourceFile.newBuilder() + .setFilePath(path) + .setFile(toFile()) + val doc = Documentation.fromFile(this) + result.putAllType( + messageTypes(path, doc) + .map { it.name.typeUrl() to it } + .toMap() + ) + result.putAllEnumType( + enumTypes(path, doc) + .map { it.name.typeUrl() to it } + .toMap() + ) + result.putAllService( + services(path, doc) + .map { it.name.typeUrl() to it } + .toMap() + ) + return result.build() +} + +private fun Descriptors.FileDescriptor.messageTypes( + path: FilePath, + doc: Documentation +): Sequence { + var messages = messageTypes.asSequence() + for (msg in messageTypes) { + messages += walkMessage(msg) { it.nestedTypes } + } + return messages.map { it.asMessage(path, doc) } +} + +private fun Descriptors.FileDescriptor.enumTypes( + path: FilePath, + doc: Documentation +): Sequence { + var enums = enumTypes.asSequence() + for (msg in messageTypes) { + enums += walkMessage(msg) { it.enumTypes } + } + return enums.map { it.asEnum(path, doc) } +} + +private fun Descriptors.FileDescriptor.services( + path: FilePath, + doc: Documentation +): Sequence = services.asSequence().map { it.asService(path, doc) } + +private fun Descriptors.Descriptor.asMessage( + path: FilePath, + documentation: Documentation +) = messageType { + val typeName = name() + name = typeName + file = path + doc = documentation.forMessage(this@asMessage) + option.addAll(listOptions(options)) + if (containingType != null) { + declaredIn = containingType.name() + } + oneofGroup.addAll(realOneofs.map { oneofGroup { + val groupName = it.name() + name = groupName + field.addAll(it.fields.map { f -> f.buildFieldWithOptions(typeName, documentation) }) + option.addAll(listOptions(options)) + doc = documentation.forOneof(it) + }}) + field.addAll(fields.map { it.buildFieldWithOptions(typeName, documentation) }) + nestedMessages.addAll(nestedTypes.map { it.name() }) + nestedEnums.addAll(enumTypes.map { it.name() }) +} + +private fun Descriptors.EnumDescriptor.asEnum( + path: FilePath, documentation: Documentation +) = enumType { + val typeName = name() + name = typeName + option.addAll(listOptions(options)) + file = path + constant.addAll(values.map { it.buildConstantWithOptions(typeName, documentation) }) + if (containingType != null) { + declaredIn = containingType.name() + } + doc = documentation.forEnum(this@asEnum) +} + +private fun Descriptors.ServiceDescriptor.asService( + path: FilePath, documentation: Documentation +) = service { + val serviceName = name() + name = serviceName + rpc.addAll(methods.map { it.buildRpcWithOptions(serviceName, documentation) }) + option.addAll(listOptions(options)) + doc = documentation.forService(this@asService) + +} + +private fun walkMessage( + type: Descriptors.Descriptor, + extractorFun: (Descriptors.Descriptor) -> Iterable +): Sequence { + val queue = ArrayDeque() + queue.add(type) + return sequence { + while (queue.isNotEmpty()) { + val msg = queue.removeFirst() + yieldAll(extractorFun(msg)) + queue.addAll(msg.nestedTypes) + } + } +} + +private fun Descriptors.FileDescriptor.toFile() = file { + path = path() + packageName = `package` + syntax = this@toFile.syntax.toSyntaxVersion() } /** @@ -79,15 +210,9 @@ private class ProtoFileEvents( private val shouldGenerate: Boolean = true ) { - private val file = File.newBuilder() - .setPath(fileDescriptor.path()) - .setPackageName(fileDescriptor.`package`) - .setSyntax(fileDescriptor.syntax.toSyntaxVersion()) - .build() + private val file = fileDescriptor.toFile() - private val documentation = Documentation( - fileDescriptor.toProto().sourceCodeInfo.locationList - ) + private val documentation = Documentation.fromFile(fileDescriptor) /** * Yields compiler events for the given file. diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/Documentation.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/Documentation.kt index d58382877..0f1edab02 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/Documentation.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/Documentation.kt @@ -39,6 +39,12 @@ internal class Documentation( locations: List ) { + companion object { + fun fromFile(file: Descriptors.FileDescriptor) = Documentation( + file.toProto().sourceCodeInfo.locationList + ) + } + private val docs: Map = locations.associateBy(LocationPath.Companion::from) diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/EnumCompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/EnumCompilerEvents.kt index ebc463ee7..f89f991fb 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/EnumCompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/EnumCompilerEvents.kt @@ -28,7 +28,6 @@ package io.spine.protodata.backend import com.google.protobuf.Descriptors import io.spine.protodata.ConstantName -import io.spine.protodata.EnumConstant import io.spine.protodata.EnumType import io.spine.protodata.File import io.spine.protodata.TypeName @@ -110,13 +109,7 @@ internal class EnumCompilerEvents( val name = ConstantName.newBuilder() .setValue(descriptor.name) .build() - val constant = EnumConstant.newBuilder() - .setName(name) - .setDeclaredIn(type) - .setNumber(descriptor.number) - .setOrderOfDeclaration(descriptor.index) - .setDoc(documentation.forEnumConstant(descriptor)) - .build() + val constant = descriptor.buildConstant(type, documentation) val path = file.path yield( EnumConstantEntered.newBuilder() diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/MessageCompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/MessageCompilerEvents.kt index 7b892fa8b..17d51f83b 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/MessageCompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/MessageCompilerEvents.kt @@ -27,8 +27,6 @@ package io.spine.protodata.backend import com.google.protobuf.Descriptors -import com.google.protobuf.Empty -import io.spine.protodata.Field import io.spine.protodata.File import io.spine.protodata.MessageType import io.spine.protodata.OneofGroup @@ -171,14 +169,7 @@ internal class MessageCompilerEvents( descriptor: Descriptors.FieldDescriptor ) { val fieldName = descriptor.name() - val field = Field.newBuilder() - .setName(fieldName) - .setDeclaringType(type) - .setNumber(descriptor.number) - .setOrderOfDeclaration(descriptor.index) - .assignTypeAndCardinality(descriptor) - .setDoc(documentation.forField(descriptor)) - .build() + val field = descriptor.buildField(type, documentation) val path = file.path yield( FieldEntered.newBuilder() @@ -206,30 +197,4 @@ internal class MessageCompilerEvents( .build() ) } - - /** - * Assigns the field type and cardinality (`map`/`list`/`oneof_name`/`single`) to the receiver - * builder. - * - * @return the receiver for method chaining. - */ - private fun Field.Builder.assignTypeAndCardinality( - desc: Descriptors.FieldDescriptor - ): Field.Builder { - if (desc.isMapField) { - val (keyField, valueField) = desc.messageType.fields - map = Field.OfMap.newBuilder() - .setKeyType(keyField.primitiveType()) - .build() - type = valueField.type() - } else { - type = desc.type() - when { - desc.isRepeated -> list = Empty.getDefaultInstance() - desc.realContainingOneof != null -> oneofName = desc.realContainingOneof.name() - else -> single = Empty.getDefaultInstance() - } - } - return this - } } diff --git a/compiler/src/main/kotlin/io/spine/protodata/backend/OptionsCompilerEvents.kt b/compiler/src/main/kotlin/io/spine/protodata/backend/OptionsCompilerEvents.kt index b1acfda23..c1ef56418 100644 --- a/compiler/src/main/kotlin/io/spine/protodata/backend/OptionsCompilerEvents.kt +++ b/compiler/src/main/kotlin/io/spine/protodata/backend/OptionsCompilerEvents.kt @@ -48,18 +48,28 @@ internal suspend fun SequenceScope.produceOptionEvents( options: GeneratedMessageV3.ExtendableMessage<*>, ctor: (Option) -> CompilerEvent ) { - options.allFields.forEach { (optionDescriptor, value) -> - if(value is Collection<*>) { - value.forEach { - val option = toOption(optionDescriptor, it!!) - yield(ctor(option)) + parseOptions(options).forEach { + yield(ctor(it)) + } +} + +internal fun listOptions(options: GeneratedMessageV3.ExtendableMessage<*>): List