From 89fe54c95199424faad6b0777d10c5a05fe3b622 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Sat, 19 Sep 2015 15:59:45 +0300 Subject: [PATCH] Remove NameResolver#getFqName, replace with getClassId --- .../jetbrains/kotlin/checkers/LazyOperationsLog.kt | 2 +- .../serialization/deserialization/NameResolver.java | 4 ---- .../deserialization/NameResolverImpl.java | 13 +------------ .../generators/protobuf/GenerateProtoBufCompare.kt | 8 +------- .../kotlin/jps/incremental/ProtoCompareGenerated.kt | 5 +---- 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt index 99dc5973016..717547633d7 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt @@ -157,7 +157,7 @@ class LazyOperationsLog( val context = typeDeserializer.field("c") val typeProto = o.field("typeProto") val text = when { - typeProto.hasClassName() -> context.nameResolver.getFqName(typeProto.className).asString() + typeProto.hasClassName() -> context.nameResolver.getClassId(typeProto.className).asSingleFqName().asString() typeProto.hasTypeParameter() -> { val classifier = (o as JetType).constructor.declarationDescriptor!! "" + classifier.name + " in " + DescriptorUtils.getFqName(classifier.containingDeclaration) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolver.java b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolver.java index 088b3d6dbc5..3165c8f42b9 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolver.java +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolver.java @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.serialization.deserialization; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.name.ClassId; -import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; public interface NameResolver { @@ -30,7 +29,4 @@ public interface NameResolver { @NotNull ClassId getClassId(int index); - - @NotNull - FqName getFqName(int index); } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolverImpl.java b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolverImpl.java index a8fa8b79bc8..5866e0a03cf 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolverImpl.java +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/NameResolverImpl.java @@ -45,7 +45,7 @@ public class NameResolverImpl implements NameResolver { private final ProtoBuf.StringTable strings; private final ProtoBuf.QualifiedNameTable qualifiedNames; - public NameResolverImpl( + private NameResolverImpl( @NotNull ProtoBuf.StringTable strings, @NotNull ProtoBuf.QualifiedNameTable qualifiedNames ) { @@ -93,15 +93,4 @@ public class NameResolverImpl implements NameResolver { return new ClassId(FqName.fromSegments(packageFqName), FqName.fromSegments(relativeClassName), local); } - - @Override - @NotNull - public FqName getFqName(int index) { - QualifiedName qualifiedName = qualifiedNames.getQualifiedName(index); - Name shortName = getName(qualifiedName.getShortName()); - if (!qualifiedName.hasParentQualifiedName()) { - return FqName.topLevel(shortName); - } - return getFqName(qualifiedName.getParentQualifiedName()).child(shortName); - } } diff --git a/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt b/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt index e30ab3efe94..bc30fe95b18 100644 --- a/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt +++ b/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt @@ -53,7 +53,6 @@ class GenerateProtoBufCompare { private val RESULT_NAME = "result" private val STRING_INDEXES_NANE = "StringIndexes" private val CLASS_ID_INDEXES_NANE = "ClassIdIndexes" - private val FQ_NAME_INDEXES_NANE = "FqNameIndexes" private val OLD_PREFIX = "old" private val NEW_PREFIX = "new" private val CHECK_EQAULS_NAME = "checkEquals" @@ -75,7 +74,6 @@ class GenerateProtoBufCompare { p.println() p.println("import org.jetbrains.kotlin.name.ClassId") - p.println("import org.jetbrains.kotlin.name.FqName") p.println("import org.jetbrains.kotlin.serialization.ProtoBuf") p.println("import org.jetbrains.kotlin.serialization.deserialization.NameResolver") p.println("import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf") @@ -95,9 +93,7 @@ class GenerateProtoBufCompare { p.println("public val $NEW_PREFIX${CLASS_ID_INDEXES_NANE}Map: MutableMap = hashMapOf()") p.println() - p.println("private val fqNames = Interner()") p.println("private val classIds = Interner()") - p.println() val fileDescriptor = DebugProtoBuf.getDescriptor() @@ -150,9 +146,7 @@ class GenerateProtoBufCompare { p.println("public fun getIndexOfClassId(index: Int, map: MutableMap, nameResolver: NameResolver): Int {") p.println(" map[index]?.let { return it }") p.println() - // TODO fqNames -> classIds - p.println(" val result = fqNames.intern(nameResolver.getFqName(index))") - //p.println(" val result = classIds.intern(nameResolver.getClassId(index))") + p.println(" val result = classIds.intern(nameResolver.getClassId(index))") p.println(" map[index] = result") p.println(" return result") p.println("}") 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 e067cae4397..07f99c5ca12 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.jps.incremental import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf @@ -33,10 +32,8 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi public val oldClassIdIndexesMap: MutableMap = hashMapOf() public val newClassIdIndexesMap: MutableMap = hashMapOf() - private val fqNames = Interner() private val classIds = Interner() - open fun checkEquals(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean { if (!checkEqualsPackageMember(old, new)) return false @@ -556,7 +553,7 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi public fun getIndexOfClassId(index: Int, map: MutableMap, nameResolver: NameResolver): Int { map[index]?.let { return it } - val result = fqNames.intern(nameResolver.getFqName(index)) + val result = classIds.intern(nameResolver.getClassId(index)) map[index] = result return result }