Moved confusing utility from KtPsiUtil (but the code in KtLightClassForExplicitDeclaration is still incorrect!)
This commit is contained in:
@@ -27,7 +27,6 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.codeInsight.CommentUtilCore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,7 +37,6 @@ import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDocElement;
|
||||
import org.jetbrains.kotlin.lexer.KtToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.name.SpecialNames;
|
||||
import org.jetbrains.kotlin.parsing.KotlinExpressionParsing;
|
||||
@@ -161,23 +159,6 @@ public class KtPsiUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/** @return <code>null</code> iff the tye has syntactic errors */
|
||||
@Nullable
|
||||
public static FqName toQualifiedName(@NotNull KtUserType userType) {
|
||||
List<String> reversedNames = Lists.newArrayList();
|
||||
|
||||
KtUserType current = userType;
|
||||
while (current != null) {
|
||||
String name = current.getReferencedName();
|
||||
if (name == null) return null;
|
||||
|
||||
reversedNames.add(name);
|
||||
current = current.getQualifier();
|
||||
}
|
||||
|
||||
return FqName.fromSegments(ContainerUtil.reverse(reversedNames));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Name getShortName(@NotNull KtAnnotationEntry annotation) {
|
||||
KtTypeReference typeReference = annotation.getTypeReference();
|
||||
|
||||
+17
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.google.common.collect.Lists
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.util.Comparing
|
||||
import com.intellij.openapi.util.Key
|
||||
@@ -31,6 +32,7 @@ import com.intellij.psi.stubs.StubElement
|
||||
import com.intellij.psi.util.CachedValue
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.codegen.binding.PsiCodegenPredictor
|
||||
@@ -327,7 +329,7 @@ open class KtLightClassForExplicitDeclaration(
|
||||
val typeElement = typeReference.typeElement
|
||||
if (typeElement !is KtUserType) continue // If it's not a user type, it's definitely not a ref to deprecated
|
||||
|
||||
val fqName = KtPsiUtil.toQualifiedName(typeElement) ?: continue
|
||||
val fqName = toQualifiedName(typeElement) ?: continue
|
||||
|
||||
if (deprecatedFqName == fqName) return true
|
||||
if (deprecatedName == fqName.asString()) return true
|
||||
@@ -335,6 +337,20 @@ open class KtLightClassForExplicitDeclaration(
|
||||
return false
|
||||
}
|
||||
|
||||
private fun toQualifiedName(userType: KtUserType): FqName? {
|
||||
val reversedNames = Lists.newArrayList<String>()
|
||||
|
||||
var current: KtUserType? = userType
|
||||
while (current != null) {
|
||||
val name = current.referencedName ?: return null
|
||||
|
||||
reversedNames.add(name)
|
||||
current = current.qualifier
|
||||
}
|
||||
|
||||
return FqName.fromSegments(ContainerUtil.reverse(reversedNames))
|
||||
}
|
||||
|
||||
override fun isInterface(): Boolean {
|
||||
if (classOrObject !is KtClass) return false
|
||||
return classOrObject.isInterface() || classOrObject.isAnnotation()
|
||||
|
||||
Reference in New Issue
Block a user