Added BodyResolveMode parameter to JetElement.analyze()
This commit is contained in:
@@ -16,13 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.caches.resolve
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
public fun JetElement.getResolutionFacade(): ResolutionFacade {
|
||||
return KotlinCacheService.getInstance(getProject()).getResolutionFacade(listOf(this))
|
||||
@@ -37,8 +38,8 @@ public fun JetDeclaration.resolveToDescriptor(): DeclarationDescriptor {
|
||||
// analyze - see ResolveSessionForBodies, ResolveElementCache
|
||||
// analyzeFully - see KotlinResolveCache, KotlinResolveDataProvider
|
||||
// In the future these two approaches should be unified
|
||||
public fun JetElement.analyze(): BindingContext {
|
||||
return getResolutionFacade().analyze(this)
|
||||
public fun JetElement.analyze(bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext {
|
||||
return getResolutionFacade().analyze(this, bodyResolveMode)
|
||||
}
|
||||
|
||||
public fun JetElement.analyzeAndGetResult(): AnalysisResult {
|
||||
|
||||
+2
-1
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -161,7 +162,7 @@ public class KotlinCallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i
|
||||
elementText = ((JetFile) element).getName();
|
||||
}
|
||||
else if (element instanceof JetNamedDeclaration) {
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element, BodyResolveMode.FULL);
|
||||
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||
if (descriptor == null) return null;
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.asJava.KotlinLightMethod;
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -87,7 +88,7 @@ public class KotlinCalleeMethodsTreeStructure extends KotlinCallTreeStructure {
|
||||
final Map<PsiReference, PsiElement> referencesToCalleeElements = new HashMap<PsiReference, PsiElement>();
|
||||
for (JetElement element : elementsToAnalyze) {
|
||||
element.accept(
|
||||
new CalleeReferenceVisitorBase(ResolvePackage.analyze(element), false) {
|
||||
new CalleeReferenceVisitorBase(ResolvePackage.analyze(element, BodyResolveMode.FULL), false) {
|
||||
@Override
|
||||
protected void processDeclaration(JetReferenceExpression reference, PsiElement declaration) {
|
||||
referencesToCalleeElements.put(reference.getReference(), declaration);
|
||||
|
||||
+2
-1
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.references.JetReference;
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchPackage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -68,7 +69,7 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure {
|
||||
|
||||
JetElement codeBlockForLocalDeclaration = getEnclosingElementForLocalDeclaration(element);
|
||||
if (codeBlockForLocalDeclaration != null) {
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element, BodyResolveMode.FULL);
|
||||
|
||||
final Map<PsiReference, PsiElement> referencesToElements = new HashMap<PsiReference, PsiElement>();
|
||||
codeBlockForLocalDeclaration.accept(new CalleeReferenceVisitorBase(bindingContext, true) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
||||
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
|
||||
import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory;
|
||||
@@ -81,6 +82,6 @@ public class ReconstructTypeInCastOrIsAction extends PsiElementBaseIntentionActi
|
||||
}
|
||||
|
||||
private static JetType getReconstructedType(JetTypeReference typeRef) {
|
||||
return ResolvePackage.analyze(typeRef).get(BindingContext.TYPE, typeRef);
|
||||
return ResolvePackage.analyze(typeRef, BodyResolveMode.FULL).get(BindingContext.TYPE, typeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
||||
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
|
||||
import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory;
|
||||
@@ -44,7 +45,7 @@ public class DeclarationUtils {
|
||||
private static JetType getPropertyTypeIfNeeded(@NotNull JetProperty property) {
|
||||
if (property.getTypeReference() != null) return null;
|
||||
|
||||
JetType type = ResolvePackage.analyze(property).get(
|
||||
JetType type = ResolvePackage.analyze(property, BodyResolveMode.FULL).get(
|
||||
BindingContext.EXPRESSION_TYPE, property.getInitializer()
|
||||
);
|
||||
return type == null || type.isError() ? null : type;
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.idea.codeInsight.ImplementMethodsHandler;
|
||||
import org.jetbrains.kotlin.psi.JetReferenceExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -60,7 +61,7 @@ class AnonymousTemplateEditingListener extends TemplateEditingAdapter {
|
||||
PsiElement name = psiFile.findElementAt(variableRange.getStartOffset());
|
||||
if (name != null && name.getParent() instanceof JetReferenceExpression) {
|
||||
JetReferenceExpression ref = (JetReferenceExpression) name.getParent();
|
||||
DeclarationDescriptor descriptor = ResolvePackage.analyze(ref).get(BindingContext.REFERENCE_TARGET, ref);
|
||||
DeclarationDescriptor descriptor = ResolvePackage.analyze(ref, BodyResolveMode.FULL).get(BindingContext.REFERENCE_TARGET, ref);
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
classRef = ref;
|
||||
classDescriptor = (ClassDescriptor) descriptor;
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
|
||||
@@ -91,7 +92,7 @@ public class JetAnonymousSuperMacro extends Macro {
|
||||
JetExpression expression = PsiTreeUtil.getParentOfType(psiFile.findElementAt(context.getStartOffset()), JetExpression.class);
|
||||
if (expression == null) return null;
|
||||
|
||||
BindingContext bc = ResolvePackage.analyze(expression);
|
||||
BindingContext bc = ResolvePackage.analyze(expression, BodyResolveMode.FULL);
|
||||
JetScope scope = bc.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||
if (scope == null) return null;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
@@ -67,7 +68,7 @@ public class JetNameSuggester {
|
||||
public static @NotNull String[] suggestNames(@NotNull JetExpression expression, @NotNull JetNameValidator validator, @Nullable String defaultName) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
|
||||
BindingContext bindingContext = ResolvePackage.analyze(expression);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(expression, BodyResolveMode.FULL);
|
||||
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (jetType != null) {
|
||||
addNamesForType(result, jetType, validator);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.kotlin.psi.JetVisitorVoid;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils;
|
||||
|
||||
@@ -73,7 +74,7 @@ public class JetNameValidatorImpl extends JetNameValidator {
|
||||
private boolean checkElement(String name, PsiElement sibling, final Set<JetScope> visitedScopes) {
|
||||
if (!(sibling instanceof JetElement)) return true;
|
||||
|
||||
final BindingContext context = ResolvePackage.analyze((JetElement) sibling);
|
||||
final BindingContext context = ResolvePackage.analyze((JetElement) sibling, BodyResolveMode.FULL);
|
||||
final Name identifier = Name.identifier(name);
|
||||
|
||||
final Ref<Boolean> result = new Ref<Boolean>(true);
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -127,7 +128,7 @@ public class JetRefactoringUtil {
|
||||
@Nullable Collection<PsiElement> ignore,
|
||||
@NotNull String actionStringKey
|
||||
) {
|
||||
BindingContext bindingContext = ResolvePackage.analyze(declaration);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(declaration, BodyResolveMode.FULL);
|
||||
|
||||
CallableDescriptor declarationDescriptor =
|
||||
(CallableDescriptor)bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||
@@ -262,7 +263,7 @@ public class JetRefactoringUtil {
|
||||
PsiElement originalDeclaration = AsJavaPackage.getUnwrapped(method);
|
||||
if (originalDeclaration instanceof JetDeclaration) {
|
||||
JetDeclaration jetDeclaration = (JetDeclaration) originalDeclaration;
|
||||
BindingContext bindingContext = ResolvePackage.analyze(jetDeclaration);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(jetDeclaration, BodyResolveMode.FULL);
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetDeclaration);
|
||||
|
||||
if (descriptor != null) return formatFunctionDescriptor(descriptor);
|
||||
@@ -272,7 +273,7 @@ public class JetRefactoringUtil {
|
||||
|
||||
@NotNull
|
||||
public static String formatClass(@NotNull JetClassOrObject classOrObject) {
|
||||
BindingContext bindingContext = ResolvePackage.analyze(classOrObject);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(classOrObject, BodyResolveMode.FULL);
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
|
||||
|
||||
if (descriptor instanceof ClassDescriptor) return formatClassDescriptor(descriptor);
|
||||
@@ -425,7 +426,7 @@ public class JetRefactoringUtil {
|
||||
}
|
||||
if (addExpression) {
|
||||
JetExpression expression = (JetExpression)element;
|
||||
BindingContext bindingContext = ResolvePackage.analyze(expression);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(expression, BodyResolveMode.FULL);
|
||||
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (expressionType == null || !KotlinBuiltIns.isUnit(expressionType)) {
|
||||
expressions.add(expression);
|
||||
|
||||
+3
-2
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TasksPackage;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -90,7 +91,7 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
JetElement jetElement = PsiTreeUtil.getParentOfType(element, JetElement.class);
|
||||
if (jetElement == null) return null;
|
||||
|
||||
BindingContext bindingContext = ResolvePackage.analyze(jetElement);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(jetElement, BodyResolveMode.FULL);
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetReferenceExpression) receiverExpr);
|
||||
|
||||
if (descriptor instanceof ClassDescriptor || descriptor instanceof FunctionDescriptor) return receiverExpr;
|
||||
@@ -105,7 +106,7 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
@NotNull Project project,
|
||||
@Nullable Editor editor
|
||||
) {
|
||||
BindingContext bindingContext = ResolvePackage.analyze(element);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(element, BodyResolveMode.FULL);
|
||||
|
||||
FunctionDescriptor functionDescriptor = findDescriptor(element, project, editor, bindingContext);
|
||||
if (functionDescriptor == null) {
|
||||
|
||||
+6
-5
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
||||
@@ -183,12 +184,12 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
JetFunction jetFunction = (JetFunction) functionUsageInfo.getDeclaration();
|
||||
JetExpression body = jetFunction.getBodyExpression();
|
||||
if (body != null) {
|
||||
body.accept(visitor, ResolvePackage.analyze(body));
|
||||
body.accept(visitor, ResolvePackage.analyze(body, BodyResolveMode.FULL));
|
||||
}
|
||||
for (JetParameter parameter : jetFunction.getValueParameters()) {
|
||||
JetExpression defaultValue = parameter.getDefaultValue();
|
||||
if (defaultValue != null) {
|
||||
defaultValue.accept(visitor, ResolvePackage.analyze(defaultValue));
|
||||
defaultValue.accept(visitor, ResolvePackage.analyze(defaultValue, BodyResolveMode.FULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,7 +288,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
JetExpression argExpression = arguments.get(0).getArgumentExpression();
|
||||
if (!(argExpression instanceof JetFunctionLiteralExpression)) continue;
|
||||
|
||||
BindingContext context = ResolvePackage.analyze(callExpression);
|
||||
BindingContext context = ResolvePackage.analyze(callExpression, BodyResolveMode.FULL);
|
||||
|
||||
JetFunctionLiteral functionLiteral = ((JetFunctionLiteralExpression) argExpression).getFunctionLiteral();
|
||||
FunctionDescriptor functionDescriptor = context.get(BindingContext.FUNCTION, functionLiteral);
|
||||
@@ -332,7 +333,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
JetChangeInfo changeInfo = (JetChangeInfo) info;
|
||||
PsiElement function = info.getMethod();
|
||||
PsiElement element = function != null ? function : changeInfo.getContext();
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element, BodyResolveMode.FULL);
|
||||
FunctionDescriptor oldDescriptor = ChangeSignaturePackage.getOriginalBaseFunctionDescriptor(changeInfo);
|
||||
DeclarationDescriptor containingDeclaration = oldDescriptor.getContainingDeclaration();
|
||||
|
||||
@@ -455,7 +456,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
JetTypeReference receiverTypeRef = psiFactory.createType(newReceiverInfo.getCurrentTypeText());
|
||||
TypeRefHelpersPackage.setReceiverTypeReference(functionWithReceiver, receiverTypeRef);
|
||||
//noinspection ConstantConditions
|
||||
BindingContext newContext = ResolvePackage.analyze(functionWithReceiver.getBodyExpression());
|
||||
BindingContext newContext = ResolvePackage.analyze(functionWithReceiver.getBodyExpression(), BodyResolveMode.FULL);
|
||||
|
||||
//noinspection ConstantConditions
|
||||
int originalOffset = ((JetNamedFunction) callable).getBodyExpression().getTextOffset();
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.idea.util.psiModificationUtil.PsiModificationUtilPac
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
||||
@@ -48,7 +49,7 @@ public class JetFunctionCallUsage extends JetUsageInfo<JetCallElement> {
|
||||
public JetFunctionCallUsage(@NotNull JetCallElement element, JetFunctionDefinitionUsage callee) {
|
||||
super(element);
|
||||
this.callee = callee;
|
||||
this.resolvedCall = CallUtilPackage.getResolvedCall(element, ResolvePackage.analyze(element));
|
||||
this.resolvedCall = CallUtilPackage.getResolvedCall(element, ResolvePackage.analyze(element, BodyResolveMode.FULL));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -231,7 +231,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
BindingContext context = ResolvePackage.analyze(initializer);
|
||||
BindingContext context = ResolvePackage.analyze(initializer, BodyResolveMode.FULL);
|
||||
SimpleFunctionDescriptor fun = context.get(BindingContext.FUNCTION, functionLiteralExpression.getFunctionLiteral());
|
||||
if (fun == null || ErrorUtils.containsErrorType(fun)) {
|
||||
return null;
|
||||
@@ -343,7 +343,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
||||
|
||||
@Nullable
|
||||
private static String getTypeArgumentsStringForCall(@NotNull JetExpression initializer) {
|
||||
BindingContext context = ResolvePackage.analyze(initializer);
|
||||
BindingContext context = ResolvePackage.analyze(initializer, BodyResolveMode.FULL);
|
||||
ResolvedCall<?> call = CallUtilPackage.getResolvedCall(initializer, context);
|
||||
if (call == null) return null;
|
||||
|
||||
|
||||
+2
-1
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.psi.JetProperty;
|
||||
import org.jetbrains.kotlin.psi.JetPsiUtil;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
@@ -93,7 +94,7 @@ class KotlinOverridingDialog extends DialogWrapper {
|
||||
private static String formatElement(PsiElement element) {
|
||||
element = JetPsiUtil.ascendIfPropertyAccessor(element);
|
||||
if (element instanceof JetNamedFunction || element instanceof JetProperty) {
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element, BodyResolveMode.FULL);
|
||||
|
||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||
if (declarationDescriptor instanceof CallableMemberDescriptor) {
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration;
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -310,7 +311,7 @@ public class JetRunConfiguration extends ModuleBasedConfiguration<RunConfigurati
|
||||
@Nullable
|
||||
private JetNamedFunction findMainFun(@NotNull Module module, @NotNull PsiClass psiClass) throws CantRunException {
|
||||
for (JetNamedFunction function : getMainFunCandidates(module, psiClass)) {
|
||||
BindingContext bindingContext = ResolvePackage.analyze(function);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(function, BodyResolveMode.FULL);
|
||||
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(bindingContext);
|
||||
if (mainFunctionDetector.isMain(function)) return function;
|
||||
}
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.psi.JetReferenceExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -111,7 +112,7 @@ public abstract class AbstractInsertImportOnPasteTest extends JetLightCodeInsigh
|
||||
DebugInfoUtil.markDebugAnnotations(file, bindingContext, new DebugInfoUtil.DebugInfoReporter() {
|
||||
@Override
|
||||
public void preProcessReference(@NotNull JetReferenceExpression expression) {
|
||||
ResolvePackage.analyze(expression);
|
||||
ResolvePackage.analyze(expression, BodyResolveMode.FULL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsPackage;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -238,7 +239,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
BindingContext context = ResolvePackage.analyze(method);
|
||||
BindingContext context = ResolvePackage.analyze(method, BodyResolveMode.FULL);
|
||||
|
||||
ChangeSignaturePackage
|
||||
.runChangeSignature(getProject(), ChangeSignaturePackage.getOriginalBaseFunctionDescriptor(changeInfo), empty, context, method, "test");
|
||||
@@ -880,7 +881,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
||||
JetElement element = (JetElement) new JetChangeSignatureHandler().findTargetMember(file, editor);
|
||||
assertNotNull("Target element is null", element);
|
||||
|
||||
BindingContext bindingContext = ResolvePackage.analyze(element);
|
||||
BindingContext bindingContext = ResolvePackage.analyze(element, BodyResolveMode.FULL);
|
||||
PsiElement context = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
assertNotNull(context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user