[kpm] IdeaKpmProtoSchema: Include message severity for future messages

^KT-52568 Verification Pending
This commit is contained in:
sebastian.sellmair
2022-06-14 14:16:01 +02:00
committed by Space
parent 12b6d32e73
commit d8ac6357a6
8 changed files with 377 additions and 63 deletions
@@ -16,6 +16,7 @@ private static final long serialVersionUID = 0L;
super(builder);
}
private IdeaKpmSchemaInfoProto() {
severity_ = 0;
message_ = "";
}
@@ -65,9 +66,15 @@ private static final long serialVersionUID = 0L;
sinceSchemaVersionPatch_ = input.readUInt32();
break;
}
case 34: {
java.lang.String s = input.readStringRequireUtf8();
case 32: {
int rawValue = input.readEnum();
bitField0_ |= 0x00000008;
severity_ = rawValue;
break;
}
case 42: {
java.lang.String s = input.readStringRequireUtf8();
bitField0_ |= 0x00000010;
message_ = s;
break;
}
@@ -103,6 +110,123 @@ private static final long serialVersionUID = 0L;
org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.class, org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Builder.class);
}
/**
* Protobuf enum {@code org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity}
*/
public enum Severity
implements com.google.protobuf.ProtocolMessageEnum {
/**
* <code>INFO = 0;</code>
*/
INFO(0),
/**
* <code>WARNING = 1;</code>
*/
WARNING(1),
/**
* <code>ERROR = 2;</code>
*/
ERROR(2),
UNRECOGNIZED(-1),
;
/**
* <code>INFO = 0;</code>
*/
public static final int INFO_VALUE = 0;
/**
* <code>WARNING = 1;</code>
*/
public static final int WARNING_VALUE = 1;
/**
* <code>ERROR = 2;</code>
*/
public static final int ERROR_VALUE = 2;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static Severity valueOf(int value) {
return forNumber(value);
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
*/
public static Severity forNumber(int value) {
switch (value) {
case 0: return INFO;
case 1: return WARNING;
case 2: return ERROR;
default: return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<Severity>
internalGetValueMap() {
return internalValueMap;
}
private static final com.google.protobuf.Internal.EnumLiteMap<
Severity> internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<Severity>() {
public Severity findValueByNumber(int number) {
return Severity.forNumber(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor
getValueDescriptor() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalStateException(
"Can't get the descriptor of an unrecognized enum value.");
}
return getDescriptor().getValues().get(ordinal());
}
public final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
return org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.getDescriptor().getEnumTypes().get(0);
}
private static final Severity[] VALUES = values();
public static Severity valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException(
"EnumValueDescriptor is not for this type.");
}
if (desc.getIndex() == -1) {
return UNRECOGNIZED;
}
return VALUES[desc.getIndex()];
}
private final int value;
private Severity(int value) {
this.value = value;
}
// @@protoc_insertion_point(enum_scope:org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity)
}
private int bitField0_;
public static final int SINCE_SCHEMA_VERSION_MAJOR_FIELD_NUMBER = 1;
private int sinceSchemaVersionMajor_;
@@ -161,18 +285,44 @@ private static final long serialVersionUID = 0L;
return sinceSchemaVersionPatch_;
}
public static final int MESSAGE_FIELD_NUMBER = 4;
public static final int SEVERITY_FIELD_NUMBER = 4;
private int severity_;
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return Whether the severity field is set.
*/
@java.lang.Override public boolean hasSeverity() {
return ((bitField0_ & 0x00000008) != 0);
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return The enum numeric value on the wire for severity.
*/
@java.lang.Override public int getSeverityValue() {
return severity_;
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return The severity.
*/
@java.lang.Override public org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity getSeverity() {
@SuppressWarnings("deprecation")
org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity result = org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity.valueOf(severity_);
return result == null ? org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity.UNRECOGNIZED : result;
}
public static final int MESSAGE_FIELD_NUMBER = 5;
private volatile java.lang.Object message_;
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return Whether the message field is set.
*/
@java.lang.Override
public boolean hasMessage() {
return ((bitField0_ & 0x00000008) != 0);
return ((bitField0_ & 0x00000010) != 0);
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return The message.
*/
@java.lang.Override
@@ -189,7 +339,7 @@ private static final long serialVersionUID = 0L;
}
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return The bytes for message.
*/
@java.lang.Override
@@ -231,7 +381,10 @@ private static final long serialVersionUID = 0L;
output.writeUInt32(3, sinceSchemaVersionPatch_);
}
if (((bitField0_ & 0x00000008) != 0)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, message_);
output.writeEnum(4, severity_);
}
if (((bitField0_ & 0x00000010) != 0)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 5, message_);
}
unknownFields.writeTo(output);
}
@@ -255,7 +408,11 @@ private static final long serialVersionUID = 0L;
.computeUInt32Size(3, sinceSchemaVersionPatch_);
}
if (((bitField0_ & 0x00000008) != 0)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, message_);
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(4, severity_);
}
if (((bitField0_ & 0x00000010) != 0)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, message_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
@@ -287,6 +444,10 @@ private static final long serialVersionUID = 0L;
if (getSinceSchemaVersionPatch()
!= other.getSinceSchemaVersionPatch()) return false;
}
if (hasSeverity() != other.hasSeverity()) return false;
if (hasSeverity()) {
if (severity_ != other.severity_) return false;
}
if (hasMessage() != other.hasMessage()) return false;
if (hasMessage()) {
if (!getMessage()
@@ -315,6 +476,10 @@ private static final long serialVersionUID = 0L;
hash = (37 * hash) + SINCE_SCHEMA_VERSION_PATCH_FIELD_NUMBER;
hash = (53 * hash) + getSinceSchemaVersionPatch();
}
if (hasSeverity()) {
hash = (37 * hash) + SEVERITY_FIELD_NUMBER;
hash = (53 * hash) + severity_;
}
if (hasMessage()) {
hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
hash = (53 * hash) + getMessage().hashCode();
@@ -458,8 +623,10 @@ private static final long serialVersionUID = 0L;
bitField0_ = (bitField0_ & ~0x00000002);
sinceSchemaVersionPatch_ = 0;
bitField0_ = (bitField0_ & ~0x00000004);
message_ = "";
severity_ = 0;
bitField0_ = (bitField0_ & ~0x00000008);
message_ = "";
bitField0_ = (bitField0_ & ~0x00000010);
return this;
}
@@ -503,6 +670,10 @@ private static final long serialVersionUID = 0L;
if (((from_bitField0_ & 0x00000008) != 0)) {
to_bitField0_ |= 0x00000008;
}
result.severity_ = severity_;
if (((from_bitField0_ & 0x00000010) != 0)) {
to_bitField0_ |= 0x00000010;
}
result.message_ = message_;
result.bitField0_ = to_bitField0_;
onBuilt();
@@ -562,8 +733,11 @@ private static final long serialVersionUID = 0L;
if (other.hasSinceSchemaVersionPatch()) {
setSinceSchemaVersionPatch(other.getSinceSchemaVersionPatch());
}
if (other.hasSeverity()) {
setSeverity(other.getSeverity());
}
if (other.hasMessage()) {
bitField0_ |= 0x00000008;
bitField0_ |= 0x00000010;
message_ = other.message_;
onChanged();
}
@@ -714,16 +888,77 @@ private static final long serialVersionUID = 0L;
return this;
}
private java.lang.Object message_ = "";
private int severity_ = 0;
/**
* <code>optional string message = 4;</code>
* @return Whether the message field is set.
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return Whether the severity field is set.
*/
public boolean hasMessage() {
@java.lang.Override public boolean hasSeverity() {
return ((bitField0_ & 0x00000008) != 0);
}
/**
* <code>optional string message = 4;</code>
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return The enum numeric value on the wire for severity.
*/
@java.lang.Override public int getSeverityValue() {
return severity_;
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @param value The enum numeric value on the wire for severity to set.
* @return This builder for chaining.
*/
public Builder setSeverityValue(int value) {
bitField0_ |= 0x00000008;
severity_ = value;
onChanged();
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return The severity.
*/
@java.lang.Override
public org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity getSeverity() {
@SuppressWarnings("deprecation")
org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity result = org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity.valueOf(severity_);
return result == null ? org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity.UNRECOGNIZED : result;
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @param value The severity to set.
* @return This builder for chaining.
*/
public Builder setSeverity(org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000008;
severity_ = value.getNumber();
onChanged();
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return This builder for chaining.
*/
public Builder clearSeverity() {
bitField0_ = (bitField0_ & ~0x00000008);
severity_ = 0;
onChanged();
return this;
}
private java.lang.Object message_ = "";
/**
* <code>optional string message = 5;</code>
* @return Whether the message field is set.
*/
public boolean hasMessage() {
return ((bitField0_ & 0x00000010) != 0);
}
/**
* <code>optional string message = 5;</code>
* @return The message.
*/
public java.lang.String getMessage() {
@@ -739,7 +974,7 @@ private static final long serialVersionUID = 0L;
}
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return The bytes for message.
*/
public com.google.protobuf.ByteString
@@ -756,7 +991,7 @@ private static final long serialVersionUID = 0L;
}
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @param value The message to set.
* @return This builder for chaining.
*/
@@ -765,23 +1000,23 @@ private static final long serialVersionUID = 0L;
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000008;
bitField0_ |= 0x00000010;
message_ = value;
onChanged();
return this;
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return This builder for chaining.
*/
public Builder clearMessage() {
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
message_ = getDefaultInstance().getMessage();
onChanged();
return this;
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @param value The bytes for message to set.
* @return This builder for chaining.
*/
@@ -791,7 +1026,7 @@ private static final long serialVersionUID = 0L;
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
bitField0_ |= 0x00000008;
bitField0_ |= 0x00000010;
message_ = value;
onChanged();
return this;
@@ -41,17 +41,33 @@ interface IdeaKpmSchemaInfoProtoOrBuilder extends
int getSinceSchemaVersionPatch();
/**
* <code>optional string message = 4;</code>
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return Whether the severity field is set.
*/
boolean hasSeverity();
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return The enum numeric value on the wire for severity.
*/
int getSeverityValue();
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return The severity.
*/
org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity getSeverity();
/**
* <code>optional string message = 5;</code>
* @return Whether the message field is set.
*/
boolean hasMessage();
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return The message.
*/
java.lang.String getMessage();
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return The bytes for message.
*/
com.google.protobuf.ByteString
@@ -284,24 +284,27 @@ final class ProtoIdeaKpm {
"eaKpmModuleProtoB\t\n\007_extrasB\030\n\026_gradle_p" +
"lugin_versionB\031\n\027_core_libraries_version" +
"B\037\n\035_explicit_api_mode_cli_optionB\025\n\023_ko" +
"tlin_native_home\"\222\002\n\026IdeaKpmSchemaInfoPr" +
"tlin_native_home\"\252\003\n\026IdeaKpmSchemaInfoPr" +
"oto\022\'\n\032since_schema_version_major\030\001 \001(\rH" +
"\000\210\001\001\022\'\n\032since_schema_version_minor\030\002 \001(\r" +
"H\001\210\001\001\022\'\n\032since_schema_version_patch\030\003 \001(" +
"\rH\002\210\001\001\022\024\n\007message\030\004 \001(\tH\003\210\001\001B\035\n\033_since_s" +
"chema_version_majorB\035\n\033_since_schema_ver" +
"sion_minorB\035\n\033_since_schema_version_patc" +
"hB\n\n\010_message\"\372\002\n\025IdeaKpmContainerProto\022" +
"!\n\024schema_version_major\030\001 \001(\rH\000\210\001\001\022!\n\024sc" +
"hema_version_minor\030\002 \001(\rH\001\210\001\001\022!\n\024schema_" +
"version_patch\030\003 \001(\rH\002\210\001\001\022Q\n\014schema_infos" +
"\030\004 \003(\0132;.org.jetbrains.kotlin.kpm.idea.p" +
"roto.IdeaKpmSchemaInfoProto\022N\n\007project\030\030" +
" \001(\01328.org.jetbrains.kotlin.kpm.idea.pro" +
"to.IdeaKpmProjectProtoH\003\210\001\001B\027\n\025_schema_v" +
"ersion_majorB\027\n\025_schema_version_minorB\027\n" +
"\025_schema_version_patchB\n\n\010_projectB\002P\001b\006" +
"proto3"
"\rH\002\210\001\001\022[\n\010severity\030\004 \001(\0162D.org.jetbrains" +
".kotlin.kpm.idea.proto.IdeaKpmSchemaInfo" +
"Proto.SeverityH\003\210\001\001\022\024\n\007message\030\005 \001(\tH\004\210\001" +
"\001\",\n\010Severity\022\010\n\004INFO\020\000\022\013\n\007WARNING\020\001\022\t\n\005" +
"ERROR\020\002B\035\n\033_since_schema_version_majorB\035" +
"\n\033_since_schema_version_minorB\035\n\033_since_" +
"schema_version_patchB\013\n\t_severityB\n\n\010_me" +
"ssage\"\372\002\n\025IdeaKpmContainerProto\022!\n\024schem" +
"a_version_major\030\001 \001(\rH\000\210\001\001\022!\n\024schema_ver" +
"sion_minor\030\002 \001(\rH\001\210\001\001\022!\n\024schema_version_" +
"patch\030\003 \001(\rH\002\210\001\001\022Q\n\014schema_infos\030\004 \003(\0132;" +
".org.jetbrains.kotlin.kpm.idea.proto.Ide" +
"aKpmSchemaInfoProto\022N\n\007project\030\030 \001(\01328.o" +
"rg.jetbrains.kotlin.kpm.idea.proto.IdeaK" +
"pmProjectProtoH\003\210\001\001B\027\n\025_schema_version_m" +
"ajorB\027\n\025_schema_version_minorB\027\n\025_schema" +
"_version_patchB\n\n\010_projectB\002P\001b\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@@ -439,7 +442,7 @@ final class ProtoIdeaKpm {
internal_static_org_jetbrains_kotlin_kpm_idea_proto_IdeaKpmSchemaInfoProto_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_org_jetbrains_kotlin_kpm_idea_proto_IdeaKpmSchemaInfoProto_descriptor,
new java.lang.String[] { "SinceSchemaVersionMajor", "SinceSchemaVersionMinor", "SinceSchemaVersionPatch", "Message", "SinceSchemaVersionMajor", "SinceSchemaVersionMinor", "SinceSchemaVersionPatch", "Message", });
new java.lang.String[] { "SinceSchemaVersionMajor", "SinceSchemaVersionMinor", "SinceSchemaVersionPatch", "Severity", "Message", "SinceSchemaVersionMajor", "SinceSchemaVersionMinor", "SinceSchemaVersionPatch", "Severity", "Message", });
internal_static_org_jetbrains_kotlin_kpm_idea_proto_IdeaKpmContainerProto_descriptor =
getDescriptor().getMessageTypes().get(21);
internal_static_org_jetbrains_kotlin_kpm_idea_proto_IdeaKpmContainerProto_fieldAccessorTable = new
@@ -95,7 +95,31 @@ internal object IdeaKpmSchemaInfoProtoKt {
}
/**
* <code>optional string message = 4;</code>
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
*/
internal var severity: org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity
@JvmName("getSeverity")
get() = _builder.getSeverity()
@JvmName("setSeverity")
set(value) {
_builder.setSeverity(value)
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
*/
internal fun clearSeverity() {
_builder.clearSeverity()
}
/**
* <code>optional .org.jetbrains.kotlin.kpm.idea.proto.IdeaKpmSchemaInfoProto.Severity severity = 4;</code>
* @return Whether the severity field is set.
*/
internal fun hasSeverity(): kotlin.Boolean {
return _builder.hasSeverity()
}
/**
* <code>optional string message = 5;</code>
*/
internal var message: kotlin.String
@JvmName("getMessage")
@@ -105,13 +129,13 @@ internal object IdeaKpmSchemaInfoProtoKt {
_builder.setMessage(value)
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
*/
internal fun clearMessage() {
_builder.clearMessage()
}
/**
* <code>optional string message = 4;</code>
* <code>optional string message = 5;</code>
* @return Whether the message field is set.
*/
internal fun hasMessage(): kotlin.Boolean {
@@ -15,6 +15,7 @@ internal object IdeaKpmProtoSchema {
sinceSchemaVersionMajor = 1
sinceSchemaVersionMinor = 0
sinceSchemaVersionPatch = 0
severity = IdeaKpmSchemaInfoProto.Severity.INFO
message = "Initial version of IdeaKpmProto*"
}
)
@@ -76,24 +76,46 @@ internal fun IdeaKpmSerializationContext.IdeaKpmProject(proto: IdeaKpmContainerP
return null
}
if (proto.schemaVersionMajor > IdeaKpmProtoSchema.versionMajor) {
if (!proto.hasSchemaVersionPatch()) {
logger.warn("Missing 'schema_version_patch", Throwable())
}
val messagesFromFuture = proto.schemaInfosList.filter { schemaInfo ->
val sinceMajor = schemaInfo.sinceSchemaVersionMajor
val sinceMinor = schemaInfo.sinceSchemaVersionMinor
val sincePatch = schemaInfo.sinceSchemaVersionPatch
sinceMajor > IdeaKpmProtoSchema.versionMajor ||
(sinceMajor == IdeaKpmProtoSchema.versionMajor && IdeaKpmProtoSchema.versionMinor > IdeaKpmProtoSchema.versionMinor) ||
(sinceMajor == IdeaKpmProtoSchema.versionMajor && sinceMinor == IdeaKpmProtoSchema.versionMinor &&
sincePatch > IdeaKpmProtoSchema.versionPatch)
}
messagesFromFuture.forEach { messageFromFuture ->
val userMessage = "Since: " +
"${messageFromFuture.sinceSchemaVersionMajor}." +
"${messageFromFuture.sinceSchemaVersionMinor}." +
"${messageFromFuture.sinceSchemaVersionPatch}: " +
messageFromFuture.message
when (messageFromFuture.severity) {
IdeaKpmSchemaInfoProto.Severity.INFO -> logger.warn("Info: $userMessage")
IdeaKpmSchemaInfoProto.Severity.WARNING -> logger.warn("Warn: $userMessage")
IdeaKpmSchemaInfoProto.Severity.ERROR,
IdeaKpmSchemaInfoProto.Severity.UNRECOGNIZED,
null -> logger.error("Error: $userMessage")
}
}
if (messagesFromFuture.any { it.severity == IdeaKpmSchemaInfoProto.Severity.ERROR }) {
val schemaVersionMajor = proto.schemaVersionMajor
val schemaVersionMinor = proto.schemaVersionMinor
val schemaVersionPatch = if (proto.hasSchemaVersionPatch()) proto.schemaVersionPatch else 0
logger.error(
"Incompatible IdeaKpmProto* version. Received major version ${proto.schemaVersionMajor}. " +
"Supported version ${IdeaKpmProtoSchema.versionMajor}", Throwable()
"Binary version $schemaVersionMajor.$schemaVersionMinor.$schemaVersionPatch is incompatible with this schema version: " +
"${IdeaKpmProtoSchema.versionMajor}.${IdeaKpmProtoSchema.versionMinor}.${IdeaKpmProtoSchema.versionPatch}"
)
val relevantInfos = proto.schemaInfosList.filter { info ->
info.sinceSchemaVersionMajor > IdeaKpmProtoSchema.versionMajor
}
relevantInfos.forEach { info ->
logger.error(
"Since: ${info.sinceSchemaVersionMajor}.${info.sinceSchemaVersionMinor}.${info.sinceSchemaVersionPatch}: ${info.message}"
)
}
return null
}
@@ -146,10 +146,17 @@ message IdeaKpmProjectProto {
}
message IdeaKpmSchemaInfoProto {
enum Severity {
INFO = 0;
WARNING = 1;
ERROR = 2;
};
optional uint32 since_schema_version_major = 1;
optional uint32 since_schema_version_minor = 2;
optional uint32 since_schema_version_patch = 3;
optional string message = 4;
optional Severity severity = 4;
optional string message = 5;
}
message IdeaKpmContainerProto {
@@ -157,6 +164,5 @@ message IdeaKpmContainerProto {
optional uint32 schema_version_minor = 2;
optional uint32 schema_version_patch = 3;
repeated IdeaKpmSchemaInfoProto schema_infos = 4;
optional IdeaKpmProjectProto project = 24;
}
@@ -19,11 +19,18 @@ class ContainerTest : IdeaKpmSerializationContext {
override val extrasSerializationExtension = TestIdeaKpmExtrasSerializationExtension
@Test
fun `deserialize - with too high major version - returns null`() {
fun `deserialize - with error future message - returns null`() {
val data = ideaKpmContainerProto {
schemaVersionMajor = IdeaKpmProtoSchema.versionMajor + 1
schemaVersionMinor = IdeaKpmProtoSchema.versionMinor
schemaVersionPatch = IdeaKpmProtoSchema.versionPatch
schemaInfos.add(ideaKpmSchemaInfoProto {
sinceSchemaVersionMajor = IdeaKpmProtoSchema.versionMajor + 1
sinceSchemaVersionMinor = 0
sinceSchemaVersionPatch = 0
message = "Incompatible for this test!"
severity = IdeaKpmSchemaInfoProto.Severity.ERROR
})
}.toByteArray()
assertTrue(logger.reports.isEmpty(), "Expected no reports in logger")