-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit events for all known types #127
Changes from 35 commits
fdc909b
a4f32df
1534077
77a711d
c551eb9
643ad58
b5963fd
f8ca578
9811ba2
a412d59
ea7025a
47884bb
b363bf2
7a0617e
85c211e
b105840
e078f86
281d9b1
2527f70
040fb73
ee687ae
d6d2708
f4c7a76
83f51c7
5de89bc
514ce41
e88a6bd
342ecc2
37ad5f3
1a25dbd
5ebf770
6dddbbe
796127d
51ed614
07dea0f
c477f1b
c8b2a60
0fa23c7
d6133ec
af59295
cd18964
113e558
518c8b2
8e207c1
5a11ddd
ff3ab1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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 | ||
|
||
import com.google.protobuf.Message | ||
import io.spine.annotation.GeneratedMixin | ||
import io.spine.annotation.Internal | ||
|
||
/** | ||
* A high-level Protobuf declaration, such as a message, an enum, or a service. | ||
*/ | ||
@Internal | ||
@GeneratedMixin | ||
public interface ProtoDeclaration : Message { | ||
|
||
/** | ||
* Obtains the name of this Protobuf declaration. | ||
*/ | ||
public val name: ProtoDeclarationName | ||
|
||
/** | ||
* Obtains the type URl of the type. | ||
* | ||
* A type URL contains the type URL prefix and the qualified name of the type separated by | ||
* the slash (`/`) symbol. See the docs of `google.protobuf.Any.type_url` for more info. | ||
*/ | ||
public fun typeUrl(): String? { | ||
return name.typeUrl() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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 | ||
|
||
import com.google.protobuf.Message | ||
import io.spine.annotation.GeneratedMixin | ||
import io.spine.annotation.Internal | ||
|
||
/** | ||
* Name of a high-level Protobuf declaration. | ||
*/ | ||
@Internal | ||
@GeneratedMixin | ||
public interface ProtoDeclarationName : Message { | ||
|
||
/** | ||
* Prints this name as a type URL. | ||
* | ||
* A type URL contains the type URL prefix and the qualified name of the type separated by | ||
* the slash (`/`) symbol. See the docs of `google.protobuf.Any.type_url` for more info. | ||
*/ | ||
public fun typeUrl(): String | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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 | ||
|
||
import io.spine.annotation.GeneratedMixin | ||
import io.spine.annotation.Internal | ||
|
||
/** | ||
* Name of a service declared in Protobuf. | ||
*/ | ||
@Internal | ||
@GeneratedMixin | ||
public interface ServiceNameMixin : ProtoDeclarationName, ServiceNameOrBuilder { | ||
|
||
override fun typeUrl(): String { | ||
return "$typeUrlPrefix/$packageName.$simpleName" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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 | ||
|
||
import io.spine.annotation.GeneratedMixin | ||
import io.spine.annotation.Internal | ||
|
||
/** | ||
* Name of a message or enum type. | ||
*/ | ||
@Internal | ||
@GeneratedMixin | ||
public interface TypeNameMixin : ProtoDeclarationName, TypeNameOrBuilder { | ||
|
||
override fun typeUrl(): String { | ||
return "$typeUrlPrefix/${qualifiedName()}" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ option java_outer_classname = "EventsProto"; | |
option java_multiple_files = true; | ||
|
||
import "spine/protodata/ast.proto"; | ||
import "spine/protodata/source.proto"; | ||
|
||
// Emitted when processing of a file begins. | ||
message FileEntered { | ||
|
@@ -264,3 +265,23 @@ message RpcExited { | |
|
||
RpcName rpc = 3; | ||
} | ||
|
||
// Emitted when the Protobuf compiler discovers a dependency file. | ||
// | ||
// The order of files reported by events of this type is unspecified. Users should not rely on any | ||
// particular order. | ||
// | ||
// Each file is only reported by one event, even if the file is imported into | ||
// | ||
// `DependencyDiscovered` events always precede all other Protobuf compiler events, i.e. | ||
// the first `FileEntered` will always be emitted after the last `DependencyDiscovered`. | ||
// | ||
// Normally, no code should be generated for dependencies. However, they can be used for additional | ||
// info when generating code for the module's own types. | ||
// | ||
message DependencyDiscovered { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would be more precise with this name, so that Java- and Proto-level dependencies could be distinguished. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the doc somewhat. I'd like to avoid adding the
|
||
|
||
FilePath path = 1; | ||
|
||
ProtobufSourceFile file = 2; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the return value can really be
null
, please document when such a case can occur.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProtoDeclarationName
has a similar method that returns non-nullableString
. How these two types are different in that regards?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that was a mistake. Fixed it.