More uses of partial body resolve
This commit is contained in:
+2
-1
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.util.supertypesWithAny
|
||||
@@ -546,7 +547,7 @@ class BasicCompletionSession(
|
||||
|
||||
override fun doComplete() {
|
||||
val classOrObject = position.parents.firstIsInstanceOrNull<KtClassOrObject>() ?: return
|
||||
val classDescriptor = resolutionFacade.resolveToDescriptor(classOrObject) as ClassDescriptor
|
||||
val classDescriptor = resolutionFacade.resolveToDescriptor(classOrObject, BodyResolveMode.PARTIAL) as ClassDescriptor
|
||||
var superClasses = classDescriptor.defaultType.constructor.supertypesWithAny()
|
||||
.mapNotNull { it.constructor.declarationDescriptor as? ClassDescriptor }
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.idea.imports.importableFqName
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
class KotlinCompletionStatistician : CompletionStatistician() {
|
||||
override fun serialize(element: LookupElement, location: CompletionLocation): StatisticsInfo? {
|
||||
@@ -53,7 +54,7 @@ class KotlinCompletionStatistician : CompletionStatistician() {
|
||||
class KotlinProximityStatistician : ProximityStatistician() {
|
||||
override fun serialize(element: PsiElement, location: ProximityLocation): StatisticsInfo? {
|
||||
if (element !is KtDeclaration) return null
|
||||
val descriptor = element.resolveToDescriptor()
|
||||
val descriptor = element.resolveToDescriptor(BodyResolveMode.PARTIAL)
|
||||
return KotlinStatisticsInfo.forDescriptor(descriptor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ class ExpectedInfos(
|
||||
|
||||
val loopVar = forExpression.loopParameter
|
||||
val loopVarType = if (loopVar != null && loopVar.typeReference != null)
|
||||
(resolutionFacade.resolveToDescriptor(loopVar) as VariableDescriptor).type.check { !it.isError }
|
||||
(bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, loopVar] as VariableDescriptor).type.check { !it.isError }
|
||||
else
|
||||
null
|
||||
|
||||
@@ -617,7 +617,7 @@ class ExpectedInfos(
|
||||
private fun calculateForPropertyDelegate(expressionWithType: KtExpression): Collection<ExpectedInfo>? {
|
||||
val delegate = expressionWithType.parent as? KtPropertyDelegate ?: return null
|
||||
val propertyDeclaration = delegate.parent as? KtProperty ?: return null
|
||||
val property = resolutionFacade.resolveToDescriptor(propertyDeclaration) as? PropertyDescriptor ?: return null
|
||||
val property = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, propertyDeclaration] as? PropertyDescriptor ?: return null
|
||||
|
||||
val scope = expressionWithType.getResolutionScope(bindingContext, resolutionFacade)
|
||||
val propertyOwnerType = property.fuzzyExtensionReceiverType()
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
@@ -51,7 +51,7 @@ class KotlinNameSuggestionProvider : NameSuggestionProvider {
|
||||
this += KotlinNameSuggester.getCamelNames(name!!, validator, name.first().isLowerCase())
|
||||
}
|
||||
|
||||
val callableDescriptor = element.resolveToDescriptor() as CallableDescriptor
|
||||
val callableDescriptor = element.resolveToDescriptor(BodyResolveMode.PARTIAL) as CallableDescriptor
|
||||
val type = callableDescriptor.returnType
|
||||
if (type != null && !type.isUnit() && !KotlinBuiltIns.isPrimitiveType(type)) {
|
||||
this += KotlinNameSuggester.suggestNamesByType(type, validator)
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorResolver
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParentheses
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
inline fun <reified T: PsiElement> PsiElement.replaced(newElement: T): T {
|
||||
@@ -205,7 +206,7 @@ fun KtDeclaration.implicitVisibility(): KtModifierKeywordToken? =
|
||||
else KtTokens.DEFAULT_VISIBILITY_KEYWORD
|
||||
}
|
||||
else if (hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
|
||||
(resolveToDescriptor() as? CallableMemberDescriptor)
|
||||
(resolveToDescriptor(BodyResolveMode.PARTIAL) as? CallableMemberDescriptor)
|
||||
?.overriddenDescriptors
|
||||
?.let { OverridingUtil.findMaxVisibility(it) }
|
||||
?.toKeywordToken()
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.isVisible
|
||||
@@ -57,7 +56,7 @@ object SuperClassNotInitialized : KotlinIntentionActionsFactory() {
|
||||
if (type.isError) return emptyList()
|
||||
|
||||
val superClass = (type.constructor.declarationDescriptor as? ClassDescriptor) ?: return emptyList()
|
||||
val classDescriptor = delegator.getResolutionFacade().resolveToDescriptor(classOrObjectDeclaration) as ClassDescriptor
|
||||
val classDescriptor = classOrObjectDeclaration.resolveToDescriptor() as ClassDescriptor
|
||||
val constructors = superClass.constructors.filter { it.isVisible(classDescriptor) }
|
||||
if (constructors.isEmpty()) return emptyList() // no accessible constructor
|
||||
|
||||
|
||||
+1
-1
@@ -916,7 +916,7 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor {
|
||||
baseFunction = baseFunction.createPrimaryConstructorIfAbsent()
|
||||
}
|
||||
val resolutionFacade = baseFunction.getResolutionFacade()
|
||||
val baseFunctionDescriptor = resolutionFacade.resolveToDescriptor(baseFunction) as FunctionDescriptor
|
||||
val baseFunctionDescriptor = baseFunction.resolveToDescriptor() as FunctionDescriptor
|
||||
val methodDescriptor = KotlinChangeSignatureData(baseFunctionDescriptor, baseFunction, listOf(baseFunctionDescriptor))
|
||||
|
||||
val dummyClass = JavaPsiFacade.getElementFactory(method.project).createClass("Dummy")
|
||||
|
||||
+2
-1
@@ -60,6 +60,7 @@ import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -98,7 +99,7 @@ public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase {
|
||||
this.project = project;
|
||||
this.innerClass = innerClass;
|
||||
this.targetContainer = targetContainer;
|
||||
this.innerClassDescriptor = (ClassDescriptor) ResolutionUtils.resolveToDescriptor(innerClass);
|
||||
this.innerClassDescriptor = (ClassDescriptor) ResolutionUtils.resolveToDescriptor(innerClass, BodyResolveMode.FULL);
|
||||
setTitle("Move Nested Classes to Upper Level");
|
||||
init();
|
||||
packageNameLabel.setLabelFor(packageNameField.getChildComponent());
|
||||
|
||||
+4
-4
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getJavaClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMemberDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.getOrCreateCompanionObject
|
||||
import org.jetbrains.kotlin.idea.refactoring.isInterfaceClass
|
||||
import org.jetbrains.kotlin.idea.refactoring.j2k
|
||||
@@ -52,11 +53,10 @@ class JavaToKotlinPushDownDelegate : JavaPushDownDelegate() {
|
||||
super.checkTargetClassConflicts(targetClass, pushDownData, conflicts, subClassData)
|
||||
|
||||
val ktClass = targetClass?.unwrapped as? KtClassOrObject ?: return
|
||||
val resolutionFacade = ktClass.getResolutionFacade()
|
||||
val targetClassDescriptor = resolutionFacade.resolveToDescriptor(ktClass) as ClassDescriptor
|
||||
val targetClassDescriptor = ktClass.resolveToDescriptor() as ClassDescriptor
|
||||
for (memberInfo in pushDownData.membersToMove) {
|
||||
val member = memberInfo.member ?: continue
|
||||
checkExternalUsages(conflicts, member, targetClassDescriptor, resolutionFacade)
|
||||
checkExternalUsages(conflicts, member, targetClassDescriptor, ktClass.getResolutionFacade())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class JavaToKotlinPushDownDelegate : JavaPushDownDelegate() {
|
||||
val subClass = targetClass.unwrapped as? KtClassOrObject ?: return
|
||||
val resolutionFacade = subClass.getResolutionFacade()
|
||||
val superClassDescriptor = superClass.getJavaClassDescriptor(resolutionFacade) ?: return
|
||||
val subClassDescriptor = resolutionFacade.resolveToDescriptor(subClass) as ClassDescriptor
|
||||
val subClassDescriptor = subClass.resolveToDescriptor() as ClassDescriptor
|
||||
val substitutor = getTypeSubstitutor(superClassDescriptor.defaultType, subClassDescriptor.defaultType) ?: TypeSubstitutor.EMPTY
|
||||
val psiFactory = KtPsiFactory(subClass)
|
||||
var hasAbstractMembers = false
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.util.getAllAccessibleFunctions
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
@@ -62,7 +63,7 @@ class AutomaticOverloadsRenamer(function: KtNamedFunction, newName: String) : Au
|
||||
private fun KtNamedFunction.getOverloads(): Collection<FunctionDescriptor> {
|
||||
val name = nameAsName ?: return emptyList()
|
||||
val resolutionFacade = getResolutionFacade()
|
||||
val descriptor = resolutionFacade.resolveToDescriptor(this) as CallableDescriptor
|
||||
val descriptor = this.resolveToDescriptor() as CallableDescriptor
|
||||
val context = resolutionFacade.analyze(this, BodyResolveMode.FULL)
|
||||
val scope = getResolutionScope(context, resolutionFacade)
|
||||
val extensionReceiverClass = descriptor.extensionReceiverParameter?.type?.constructor?.declarationDescriptor as? ClassDescriptor
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtTreeVisitorVoid;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -82,7 +83,7 @@ public abstract class AbstractPsiCheckerTest extends KotlinLightCodeInsightFixtu
|
||||
@Override
|
||||
public void visitDeclaration(@NotNull KtDeclaration dcl) {
|
||||
if (areDescriptorsCreatedForDeclaration(dcl)) {
|
||||
ResolutionUtils.resolveToDescriptor(dcl); // check for exceptions
|
||||
ResolutionUtils.resolveToDescriptor(dcl, BodyResolveMode.FULL); // check for exceptions
|
||||
}
|
||||
dcl.acceptChildren(this, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user