Replace JavaClassifierType.canonicalText with classifierQualifiedName
The reason is that canonicalText requires some additional computations to be done when reading class files, while in fact we only need a class name of the type
This commit is contained in:
+2
-2
@@ -71,8 +71,8 @@ public class JavaClassifierTypeImpl extends JavaTypeImpl<PsiClassType> implement
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getCanonicalText() {
|
||||
return getPsi().getCanonicalText();
|
||||
public String getClassifierQualifiedName() {
|
||||
return ClassNamesUtilKt.convertCanonicalNameToQName(getPsi().getCanonicalText());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,21 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.types
|
||||
package org.jetbrains.kotlin.load.java.structure.impl
|
||||
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
/**
|
||||
* Parse the given FQ name with possible generic arguments to a **top-level** ClassId instance.
|
||||
* E.g. "test.A<B>.C<D, E>" is parsed to a ClassId "test/A/C" which represents a class named "C" declared in package "test.A".
|
||||
*/
|
||||
internal fun parseCanonicalFqNameIgnoringTypeArguments(fqName: String): ClassId {
|
||||
val nameParts = fqName.splitCanonicalFqName()
|
||||
val resultingClassFqName = FqName(nameParts.joinToString(separator = ".") { it.substringBefore('<') })
|
||||
return ClassId.topLevel(resultingClassFqName)
|
||||
}
|
||||
fun String.convertCanonicalNameToQName() = splitCanonicalFqName().joinToString(separator = ".") { it.substringBefore('<') }
|
||||
|
||||
// "test.A<B.C>.D<E<F.G, H>, I.J>" -> ["test", "A<B.C>", "D<E<F.G, H>, I.J>"]
|
||||
private fun String.splitCanonicalFqName(): List<String> {
|
||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.lazy.TypeParameterResolver
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.*
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.types.*
|
||||
@@ -138,7 +139,7 @@ class JavaTypeResolver(
|
||||
// and treat the resulting qualified name as if it references a simple top-level class.
|
||||
// Note that this makes MISSING_DEPENDENCY_CLASS diagnostic messages not as precise as they could be in some corner cases.
|
||||
private fun createNotFoundClass(javaType: JavaClassifierType): TypeConstructor {
|
||||
val classId = parseCanonicalFqNameIgnoringTypeArguments(javaType.canonicalText)
|
||||
val classId = ClassId.topLevel(FqName(javaType.classifierQualifiedName))
|
||||
return c.components.deserializedDescriptorResolver.components.notFoundClasses.getClass(classId, listOf(0)).typeConstructor
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ interface JavaClassifierType : JavaType, JavaAnnotationOwner {
|
||||
|
||||
val isRaw: Boolean
|
||||
|
||||
val canonicalText: String
|
||||
val classifierQualifiedName: String
|
||||
val presentableText: String
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class ReflectJavaClassifierType(public override val reflectType: Type) : Reflect
|
||||
classifier
|
||||
}
|
||||
|
||||
override val canonicalText: String
|
||||
override val classifierQualifiedName: String
|
||||
get() = throw UnsupportedOperationException("Type not found: $reflectType")
|
||||
|
||||
override val presentableText: String
|
||||
|
||||
Reference in New Issue
Block a user