diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/DebugExtOptionsProtoBuf.java b/compiler/tests/org/jetbrains/kotlin/serialization/DebugExtOptionsProtoBuf.java
index cd574979e5b..371ef02abc2 100644
--- a/compiler/tests/org/jetbrains/kotlin/serialization/DebugExtOptionsProtoBuf.java
+++ b/compiler/tests/org/jetbrains/kotlin/serialization/DebugExtOptionsProtoBuf.java
@@ -10,6 +10,7 @@ public final class DebugExtOptionsProtoBuf {
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.skipInComparison);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.fqNameIdInTable);
+ registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.stringIdInTable);
}
public static final int SKIP_IN_COMPARISON_FIELD_NUMBER = 50000;
/**
@@ -44,6 +45,17 @@ public final class DebugExtOptionsProtoBuf {
.newFileScopedGeneratedExtension(
java.lang.Boolean.class,
null);
+ public static final int STRING_ID_IN_TABLE_FIELD_NUMBER = 50003;
+ /**
+ * extend .google.protobuf.FieldOptions { ... }
+ */
+ public static final
+ com.google.protobuf.GeneratedMessage.GeneratedExtension<
+ com.google.protobuf.DescriptorProtos.FieldOptions,
+ java.lang.Boolean> stringIdInTable = com.google.protobuf.GeneratedMessage
+ .newFileScopedGeneratedExtension(
+ java.lang.Boolean.class,
+ null);
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
@@ -60,8 +72,9 @@ public final class DebugExtOptionsProtoBuf {
".FieldOptions\030\320\206\003 \001(\010:9\n\020name_id_in_tabl" +
"e\022\035.google.protobuf.FieldOptions\030\321\206\003 \001(\010" +
":<\n\023fq_name_id_in_table\022\035.google.protobu" +
- "f.FieldOptions\030\322\206\003 \001(\010B\034B\027DebugExtOption" +
- "sProtoBuf\210\001\000"
+ "f.FieldOptions\030\322\206\003 \001(\010:;\n\022string_id_in_t" +
+ "able\022\035.google.protobuf.FieldOptions\030\323\206\003 " +
+ "\001(\010B\034B\027DebugExtOptionsProtoBuf\210\001\000"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -71,6 +84,7 @@ public final class DebugExtOptionsProtoBuf {
skipInComparison.internalInit(descriptor.getExtensions().get(0));
nameIdInTable.internalInit(descriptor.getExtensions().get(1));
fqNameIdInTable.internalInit(descriptor.getExtensions().get(2));
+ stringIdInTable.internalInit(descriptor.getExtensions().get(3));
return null;
}
};
diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java b/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
index 2f2b6fac81a..827cc27c4fa 100644
--- a/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
+++ b/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
@@ -17280,7 +17280,7 @@ public final class DebugProtoBuf {
".kotlin.serialization.Annotation.Argumen",
"t.Value.Type\022\021\n\tint_value\030\002 \001(\022\022\023\n\013float" +
"_value\030\003 \001(\002\022\024\n\014double_value\030\004 \001(\001\022\032\n\014st" +
- "ring_value\030\005 \001(\005B\004\210\265\030\001\022\026\n\010class_id\030\006 \001(\005" +
+ "ring_value\030\005 \001(\005B\004\230\265\030\001\022\026\n\010class_id\030\006 \001(\005" +
"B\004\220\265\030\001\022\033\n\renum_value_id\030\007 \001(\005B\004\210\265\030\001\022B\n\na" +
"nnotation\030\010 \001(\0132..org.jetbrains.kotlin.s" +
"erialization.Annotation\022T\n\rarray_element" +
@@ -17295,7 +17295,7 @@ public final class DebugProtoBuf {
"\030\002 \003(\01321.org.jetbrains.kotlin.serializat" +
"ion.Type.Argument\022\027\n\010nullable\030\003 \001(\010:\005fal" +
"se\022+\n\035flexible_type_capabilities_id\030\004 \001(" +
- "\005B\004\210\265\030\001\022F\n\024flexible_upper_bound\030\005 \001(\0132(." +
+ "\005B\004\230\265\030\001\022F\n\024flexible_upper_bound\030\005 \001(\0132(." +
"org.jetbrains.kotlin.serialization.Type\022" +
"$\n\026constructor_class_name\030\006 \001(\005B\004\220\265\030\001\022\"\n",
"\032constructor_type_parameter\030\007 \001(\005\032\234\001\n\013Co" +
@@ -17458,10 +17458,10 @@ public final class DebugProtoBuf {
com.google.protobuf.ExtensionRegistry.newInstance();
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.fqNameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
- registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
+ registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.stringIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.fqNameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
- registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
+ registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.stringIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.fqNameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.skipInComparison);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.skipInComparison);
diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java b/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java
index 6b9e3c45520..62db2dd32c6 100644
--- a/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java
+++ b/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java
@@ -3838,12 +3838,12 @@ public final class DebugJvmProtoBuf {
"\rPrimitiveType\022\010\n\004VOID\020\000\022\013\n\007BOOLEAN\020\001\022\010\n",
"\004CHAR\020\002\022\010\n\004BYTE\020\003\022\t\n\005SHORT\020\004\022\007\n\003INT\020\005\022\t\n" +
"\005FLOAT\020\006\022\010\n\004LONG\020\007\022\n\n\006DOUBLE\020\010\"\267\001\n\022JvmMe" +
- "thodSignature\022\022\n\004name\030\001 \002(\005B\004\210\265\030\001\022D\n\013ret" +
+ "thodSignature\022\022\n\004name\030\001 \002(\005B\004\230\265\030\001\022D\n\013ret" +
"urn_type\030\002 \002(\0132/.org.jetbrains.kotlin.se" +
"rialization.jvm.JvmType\022G\n\016parameter_typ" +
"e\030\003 \003(\0132/.org.jetbrains.kotlin.serializa" +
"tion.jvm.JvmType\"\211\001\n\021JvmFieldSignature\022\022" +
- "\n\004name\030\001 \002(\005B\004\210\265\030\001\022=\n\004type\030\002 \002(\0132/.org.j" +
+ "\n\004name\030\001 \002(\005B\004\230\265\030\001\022=\n\004type\030\002 \002(\0132/.org.j" +
"etbrains.kotlin.serialization.jvm.JvmTyp" +
"e\022!\n\022is_static_in_outer\030\003 \001(\010:\005false\"\316\002\n",
"\024JvmPropertySignature\022H\n\005field\030\001 \001(\01329.o" +
@@ -3911,8 +3911,8 @@ public final class DebugJvmProtoBuf {
com.google.protobuf.ExtensionRegistry registry =
com.google.protobuf.ExtensionRegistry.newInstance();
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.fqNameIdInTable);
- registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
- registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
+ registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.stringIdInTable);
+ registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.stringIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
return registry;
}
diff --git a/core/descriptor.loader.java/src/jvm_descriptors.proto b/core/descriptor.loader.java/src/jvm_descriptors.proto
index 4a138893ca6..89923077d53 100644
--- a/core/descriptor.loader.java/src/jvm_descriptors.proto
+++ b/core/descriptor.loader.java/src/jvm_descriptors.proto
@@ -47,13 +47,13 @@ message JvmType {
}
message JvmMethodSignature {
- required int32 name = 1 [(name_id_in_table) = true];
+ required int32 name = 1 [(string_id_in_table) = true];
required JvmType return_type = 2;
repeated JvmType parameter_type = 3;
}
message JvmFieldSignature {
- required int32 name = 1 [(name_id_in_table) = true];
+ required int32 name = 1 [(string_id_in_table) = true];
required JvmType type = 2;
// True iff this field is a backing field for a companion object and is really present as a static
diff --git a/core/deserialization/src/descriptors.proto b/core/deserialization/src/descriptors.proto
index 41165b0312d..e2a60fa1b49 100644
--- a/core/deserialization/src/descriptors.proto
+++ b/core/deserialization/src/descriptors.proto
@@ -76,7 +76,7 @@ message Annotation {
optional double double_value = 4;
// id in StringTable
- optional int32 string_value = 5 [(name_id_in_table) = true];
+ optional int32 string_value = 5 [(string_id_in_table) = true];
// If type = CLASS, FQ name id of the referenced class; if type = ENUM, FQ name id of the enum class
optional int32 class_id = 6 [(fq_name_id_in_table) = true];
@@ -133,7 +133,7 @@ message Type {
// Id in the StringTable
// If this field is set, the type is flexible.
// All the other fields and extensions represent its lower bound, and flexible_upper_bound must be set and represents its upper bound.
- optional int32 flexible_type_capabilities_id = 4 [(name_id_in_table) = true];
+ optional int32 flexible_type_capabilities_id = 4 [(string_id_in_table) = true];
// While such an "indirect" encoding helps backwards compatibility with pre-flexible-types versions of this format,
// we use it mainly to save space: having a special mandatory tag on each an every type just to have an option
diff --git a/core/deserialization/src/ext_options.proto b/core/deserialization/src/ext_options.proto
index a29861e6cdc..a7827be34c7 100644
--- a/core/deserialization/src/ext_options.proto
+++ b/core/deserialization/src/ext_options.proto
@@ -9,4 +9,5 @@ extend google.protobuf.FieldOptions {
optional bool skip_in_comparison = 50000;
optional bool name_id_in_table = 50001;
optional bool fq_name_id_in_table = 50002;
+ optional bool string_id_in_table = 50003;
}
diff --git a/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt b/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt
index 9481603d872..39898b43ca2 100644
--- a/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt
+++ b/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt
@@ -70,7 +70,7 @@ class GenerateProtoBufCompare {
p.println("open class ProtoCompareGenerated(private val oldNameResolver: NameResolver, private val newNameResolver: NameResolver) {")
p.pushIndent()
- p.println("private val nameIdMap: MutableMap = hashMapOf()")
+ p.println("private val stringIdMap: MutableMap = hashMapOf()")
p.println("private val fqNameIdMap: MutableMap = hashMapOf()")
p.println()
@@ -101,15 +101,18 @@ class GenerateProtoBufCompare {
fun generatePredefined(p: Printer) {
p.println()
- p.println("fun checkNameIdEquals(old: Int, new: Int): Boolean {")
- p.println(" nameIdMap.get(old)?.let { return it == new }")
+ p.println("fun checkStringIdEquals(old: Int, new: Int): Boolean {")
+ p.println(" stringIdMap.get(old)?.let { return it == new }")
p.println()
- p.println(" val oldValue = oldNameResolver.getName(old).asString()")
- p.println(" val newValue = newNameResolver.getName(new).asString()")
+ p.println(" val oldValue = oldNameResolver.stringTable.getString(old)")
+ p.println(" val newValue = newNameResolver.stringTable.getString(new)")
p.println()
- p.println(" return if (oldValue == newValue) { nameIdMap[old] = new; true } else false")
+ p.println(" return if (oldValue == newValue) { stringIdMap[old] = new; true } else false")
p.println("}")
+ p.println()
+ p.println("fun checkNameIdEquals(old: Int, new: Int): Boolean = checkStringIdEquals(old, new)")
+
p.println()
p.println("fun checkFqNameIdEquals(old: Int, new: Int): Boolean {")
p.println(" fqNameIdMap.get(old)?.let { return it == new }")
@@ -225,6 +228,8 @@ class GenerateProtoBufCompare {
private fun Printer.printlnIfWithComparison(field: Descriptors.FieldDescriptor, expr: String, withIndent: Boolean = false) {
val line = when {
+ field.options.getExtension(DebugExtOptionsProtoBuf.stringIdInTable) ->
+ "if (!checkStringIdEquals(old.$expr, new.$expr)) return false"
field.options.getExtension(DebugExtOptionsProtoBuf.nameIdInTable) ->
"if (!checkNameIdEquals(old.$expr, new.$expr)) return false"
field.options.getExtension(DebugExtOptionsProtoBuf.fqNameIdInTable) ->
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
index c8a62f6143e..c5d63391f5e 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
+++ b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
/** This file is generated by org.jetbrains.kotlin.generators.protobuf.GenerateProtoBufCompare. DO NOT MODIFY MANUALLY */
open class ProtoCompareGenerated(private val oldNameResolver: NameResolver, private val newNameResolver: NameResolver) {
- private val nameIdMap: MutableMap = hashMapOf()
+ private val stringIdMap: MutableMap = hashMapOf()
private val fqNameIdMap: MutableMap = hashMapOf()
@@ -152,7 +152,7 @@ open class ProtoCompareGenerated(private val oldNameResolver: NameResolver, priv
if (old.hasFlexibleTypeCapabilitiesId() != new.hasFlexibleTypeCapabilitiesId()) return false
if (old.hasFlexibleTypeCapabilitiesId()) {
- if (!checkNameIdEquals(old.flexibleTypeCapabilitiesId, new.flexibleTypeCapabilitiesId)) return false
+ if (!checkStringIdEquals(old.flexibleTypeCapabilitiesId, new.flexibleTypeCapabilitiesId)) return false
}
if (old.hasFlexibleUpperBound() != new.hasFlexibleUpperBound()) return false
@@ -221,7 +221,7 @@ open class ProtoCompareGenerated(private val oldNameResolver: NameResolver, priv
}
open fun checkEquals(old: JvmProtoBuf.JvmMethodSignature, new: JvmProtoBuf.JvmMethodSignature): Boolean {
- if (!checkNameIdEquals(old.name, new.name)) return false
+ if (!checkStringIdEquals(old.name, new.name)) return false
if (!checkEquals(old.returnType, new.returnType)) return false
@@ -300,7 +300,7 @@ open class ProtoCompareGenerated(private val oldNameResolver: NameResolver, priv
}
open fun checkEquals(old: JvmProtoBuf.JvmFieldSignature, new: JvmProtoBuf.JvmFieldSignature): Boolean {
- if (!checkNameIdEquals(old.name, new.name)) return false
+ if (!checkStringIdEquals(old.name, new.name)) return false
if (!checkEquals(old.type, new.type)) return false
@@ -335,7 +335,7 @@ open class ProtoCompareGenerated(private val oldNameResolver: NameResolver, priv
if (old.hasStringValue() != new.hasStringValue()) return false
if (old.hasStringValue()) {
- if (!checkNameIdEquals(old.stringValue, new.stringValue)) return false
+ if (!checkStringIdEquals(old.stringValue, new.stringValue)) return false
}
if (old.hasClassId() != new.hasClassId()) return false
@@ -500,15 +500,17 @@ open class ProtoCompareGenerated(private val oldNameResolver: NameResolver, priv
- fun checkNameIdEquals(old: Int, new: Int): Boolean {
- nameIdMap.get(old)?.let { return it == new }
+ fun checkStringIdEquals(old: Int, new: Int): Boolean {
+ stringIdMap.get(old)?.let { return it == new }
- val oldValue = oldNameResolver.getName(old).asString()
- val newValue = newNameResolver.getName(new).asString()
+ val oldValue = oldNameResolver.stringTable.getString(old)
+ val newValue = newNameResolver.stringTable.getString(new)
- return if (oldValue == newValue) { nameIdMap[old] = new; true } else false
+ return if (oldValue == newValue) { stringIdMap[old] = new; true } else false
}
+ fun checkNameIdEquals(old: Int, new: Int): Boolean = checkStringIdEquals(old, new)
+
fun checkFqNameIdEquals(old: Int, new: Int): Boolean {
fqNameIdMap.get(old)?.let { return it == new }