Inlined trivial method classDescriptorToDeclaration
This commit is contained in:
@@ -73,7 +73,6 @@ import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.isLocalNamedFun;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.classDescriptorToDeclaration;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
|
||||
@@ -936,7 +935,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiElement classElement = classDescriptorToDeclaration(declarationDescriptor);
|
||||
PsiElement classElement = DescriptorToSourceUtils.getSourceFromDescriptor(declarationDescriptor);
|
||||
if (classElement != null) {
|
||||
Integer lineNumber = CodegenUtil.getLineNumberForElement(classElement, false);
|
||||
if (lineNumber != null) {
|
||||
|
||||
+1
-2
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
@@ -125,7 +124,7 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
||||
return ContainerUtil.mapNotNull(classDescriptors, new Function<ClassDescriptor, JetClassOrObject>() {
|
||||
@Override
|
||||
public JetClassOrObject fun(ClassDescriptor descriptor) {
|
||||
PsiElement element = DescriptorToSourceUtils.classDescriptorToDeclaration(descriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.getSourceFromDescriptor(descriptor);
|
||||
if (element instanceof JetClassOrObject && PsiSearchScopeUtil.isInScope(searchScope, element)) {
|
||||
return (JetClassOrObject) element;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class DeclarationResolver {
|
||||
continue
|
||||
}
|
||||
|
||||
redeclarations.add(Pair(DescriptorToSourceUtils.classDescriptorToDeclaration(descriptor), descriptor.getName()))
|
||||
redeclarations.add(Pair(DescriptorToSourceUtils.getSourceFromDescriptor(descriptor), descriptor.getName()))
|
||||
if (descriptor2 is PropertyDescriptor) {
|
||||
redeclarations.add(Pair(DescriptorToSourceUtils.descriptorToDeclaration(descriptor2), descriptor2.getName()))
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class DeclarationsChecker {
|
||||
if (conflictingTypes.size() > 1) {
|
||||
DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration();
|
||||
assert containingDeclaration instanceof ClassDescriptor : containingDeclaration;
|
||||
JetClassOrObject psiElement = (JetClassOrObject) DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
JetClassOrObject psiElement = (JetClassOrObject) DescriptorToSourceUtils.getSourceFromDescriptor(classDescriptor);
|
||||
JetDelegationSpecifierList delegationSpecifierList = psiElement.getDelegationSpecifierList();
|
||||
assert delegationSpecifierList != null;
|
||||
// trace.getErrorHandler().genericError(delegationSpecifierList.getNode(), "Type parameter " + typeParameterDescriptor.getName() + " of " + containingDeclaration.getName() + " has inconsistent values: " + conflictingTypes);
|
||||
|
||||
@@ -20,7 +20,10 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.resolve.source.SourcePackage;
|
||||
|
||||
@@ -72,11 +75,6 @@ public final class DescriptorToSourceUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement classDescriptorToDeclaration(@NotNull ClassDescriptor clazz) {
|
||||
return getSourceFromDescriptor(clazz);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetFile getContainingFile(@NotNull DeclarationDescriptor declarationDescriptor) {
|
||||
// declarationDescriptor may describe a synthesized element which doesn't have PSI
|
||||
|
||||
+1
-1
@@ -633,7 +633,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull ClassDescriptor superclass
|
||||
) {
|
||||
PsiElement psiElement = DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
PsiElement psiElement = DescriptorToSourceUtils.getSourceFromDescriptor(classDescriptor);
|
||||
|
||||
PsiElement elementToMark = null;
|
||||
if (psiElement instanceof JetClassOrObject) {
|
||||
|
||||
@@ -114,7 +114,7 @@ public class JetExpectedResolveDataUtil {
|
||||
ModuleDescriptor module = LazyResolveTestUtil.resolveProject(project);
|
||||
ClassDescriptor classDescriptor = DescriptorUtilPackage.resolveTopLevelClass(module, new FqName(qualifiedName));
|
||||
assertNotNull("Class descriptor wasn't resolved: " + qualifiedName, classDescriptor);
|
||||
PsiClass psiClass = (PsiClass) DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
PsiClass psiClass = (PsiClass) DescriptorToSourceUtils.getSourceFromDescriptor(classDescriptor);
|
||||
assertNotNull("Class declaration wasn't found: " + classDescriptor, psiClass);
|
||||
return psiClass;
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
container.getContainingDeclaration() as? ClassDescriptor ?: return false
|
||||
else
|
||||
container
|
||||
val classBody = (DescriptorToSourceUtils.classDescriptorToDeclaration(scope) as? JetClassOrObject)?.getBody()
|
||||
val classBody = (DescriptorToSourceUtils.getSourceFromDescriptor(scope) as? JetClassOrObject)?.getBody()
|
||||
return classBody != null && classBody.getContainingFile() == file && classBody.isAncestor(place)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -247,7 +247,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
placement is CallablePlacement.WithReceiver -> {
|
||||
receiverClassDescriptor =
|
||||
placement.receiverTypeCandidate.theType.getConstructor().getDeclarationDescriptor() as? ClassDescriptor
|
||||
val classDeclaration = receiverClassDescriptor?.let { DescriptorToSourceUtils.classDescriptorToDeclaration(it) }
|
||||
val classDeclaration = receiverClassDescriptor?.let { DescriptorToSourceUtils.getSourceFromDescriptor(it) }
|
||||
containingElement = if (!config.isExtension && classDeclaration != null) classDeclaration else config.currentFile
|
||||
}
|
||||
else -> throw IllegalArgumentException("Unexpected placement: $placement")
|
||||
@@ -835,7 +835,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
|
||||
if (config.isExtension || receiverClassDescriptor !is JavaClassDescriptor) return false
|
||||
|
||||
val targetClass = DescriptorToSourceUtils.classDescriptorToDeclaration(receiverClassDescriptor) as? PsiClass
|
||||
val targetClass = DescriptorToSourceUtils.getSourceFromDescriptor(receiverClassDescriptor) as? PsiClass
|
||||
if (targetClass == null || !targetClass.canRefactor()) return false
|
||||
|
||||
val project = declaration.getProject()
|
||||
|
||||
Reference in New Issue
Block a user