Refactoring: Rename JetClsMethod -> JetPsiMethodWrapper
Source element in Kotlin mustn't be wrapped into read-only class-elements
This commit is contained in:
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.jetAsJava;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
|
||||
/** ClsMethod created for Kotlin declaration for it to be resolved from Java */
|
||||
public interface JetClsMethod extends PsiMethod {
|
||||
/** Java method created for Kotlin declaration to make it resolvable in Java */
|
||||
public interface KotlinLightMethod extends PsiMethod {
|
||||
JetDeclaration getOrigin();
|
||||
}
|
||||
+3
-3
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
|
||||
@@ -238,8 +238,8 @@ public class SignaturesPropagationData {
|
||||
continue;
|
||||
}
|
||||
|
||||
DeclarationDescriptor superFun = superMethod.getPsi() instanceof JetClsMethod
|
||||
? trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, ((JetClsMethod) superMethod.getPsi()).getOrigin())
|
||||
DeclarationDescriptor superFun = superMethod.getPsi() instanceof KotlinLightMethod
|
||||
? trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, ((KotlinLightMethod) superMethod.getPsi()).getOrigin())
|
||||
: findSuperFunction(superclassToFunctions.get(classFqName), superMethod);
|
||||
if (superFun == null) {
|
||||
// Super methods which are Object methods in interfaces are not loaded by JDR.
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
@@ -177,7 +177,7 @@ public class LightClassUtil {
|
||||
List<PsiMethod> methods = new SmartList<PsiMethod>();
|
||||
for (PsiMethod method : psiClass.getMethods()) {
|
||||
try {
|
||||
if (method instanceof JetClsMethod && ((JetClsMethod) method).getOrigin() == declaration) {
|
||||
if (method instanceof KotlinLightMethod && ((KotlinLightMethod) method).getOrigin() == declaration) {
|
||||
methods.add(method);
|
||||
if (!collectAll) {
|
||||
return methods;
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -110,8 +110,8 @@ public class KotlinCalleeMethodsTreeStructure extends KotlinCallTreeStructure {
|
||||
}
|
||||
|
||||
// Kotlin function or property invoked from Java code
|
||||
if (targetElement instanceof JetClsMethod) {
|
||||
return buildChildrenByKotlinTarget(descriptor, ((JetClsMethod) targetElement).getOrigin());
|
||||
if (targetElement instanceof KotlinLightMethod) {
|
||||
return buildChildrenByKotlinTarget(descriptor, ((KotlinLightMethod) targetElement).getOrigin());
|
||||
}
|
||||
|
||||
if (targetElement instanceof JetElement) {
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.jetbrains.jet.lang.descriptors.impl.LocalVariableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.NamespaceType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -116,7 +116,7 @@ public class JetRefactoringUtil {
|
||||
}
|
||||
|
||||
private static PsiElement toJetDeclarationOrMethod(PsiMethod method) {
|
||||
return (method instanceof JetClsMethod) ? ((JetClsMethod) method).getOrigin() : method;
|
||||
return (method instanceof KotlinLightMethod) ? ((KotlinLightMethod) method).getOrigin() : method;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -311,8 +311,8 @@ public class JetRefactoringUtil {
|
||||
|
||||
@NotNull
|
||||
public static String formatJavaOrLightMethod(@NotNull PsiMethod method) {
|
||||
if (method instanceof JetClsMethod) {
|
||||
JetDeclaration declaration = ((JetClsMethod) method).getOrigin();
|
||||
if (method instanceof KotlinLightMethod) {
|
||||
JetDeclaration declaration = ((KotlinLightMethod) method).getOrigin();
|
||||
BindingContext bindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) declaration.getContainingFile()).getBindingContext();
|
||||
DeclarationDescriptor descriptor =
|
||||
|
||||
+3
-4
@@ -31,8 +31,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
@@ -126,13 +125,13 @@ public final class JetChangeSignatureData implements JetMethodDescriptor {
|
||||
List<PsiMethod> jetLightMethods = ContainerUtil.filter(overridingMethods, new Condition<PsiMethod>() {
|
||||
@Override
|
||||
public boolean value(PsiMethod method) {
|
||||
return method instanceof JetClsMethod;
|
||||
return method instanceof KotlinLightMethod;
|
||||
}
|
||||
});
|
||||
List<JetDeclaration> jetFunctions = ContainerUtil.map(jetLightMethods, new Function<PsiMethod, JetDeclaration>() {
|
||||
@Override
|
||||
public JetDeclaration fun(PsiMethod method) {
|
||||
return ((JetClsMethod) method).getOrigin();
|
||||
return ((KotlinLightMethod) method).getOrigin();
|
||||
}
|
||||
});
|
||||
result.addAll(jetFunctions);
|
||||
|
||||
+13
-11
@@ -47,7 +47,7 @@ import org.jetbrains.jet.lang.descriptors.Modality;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
@@ -158,8 +158,8 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
|
||||
|
||||
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
|
||||
public static boolean isInside(@NotNull PsiElement place, @NotNull PsiElement ancestor) {
|
||||
if (ancestor instanceof JetClsMethod) {
|
||||
ancestor = ((JetClsMethod) ancestor).getOrigin();
|
||||
if (ancestor instanceof KotlinLightMethod) {
|
||||
ancestor = ((KotlinLightMethod) ancestor).getOrigin();
|
||||
}
|
||||
return JavaSafeDeleteProcessor.isInside(place, ancestor);
|
||||
}
|
||||
@@ -319,7 +319,8 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
|
||||
for (PsiMethod overridingMethod : overridingMethods) {
|
||||
Collection<PsiReference> overridingReferences =
|
||||
ReferencesSearch.search(
|
||||
overridingMethod instanceof JetClsMethod ? ((JetClsMethod) overridingMethod).getOrigin() : overridingMethod
|
||||
overridingMethod instanceof KotlinLightMethod
|
||||
? ((KotlinLightMethod) overridingMethod).getOrigin() : overridingMethod
|
||||
).findAll();
|
||||
methodToReferences.put(overridingMethod, overridingReferences);
|
||||
}
|
||||
@@ -585,7 +586,8 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
|
||||
) {
|
||||
PsiMethod[] methods = method.findSuperMethods();
|
||||
for (PsiMethod superMethod : methods) {
|
||||
PsiElement relevantElement = superMethod instanceof JetClsMethod ? ((JetClsMethod) superMethod).getOrigin() : superMethod;
|
||||
PsiElement relevantElement = superMethod instanceof KotlinLightMethod
|
||||
? ((KotlinLightMethod) superMethod).getOrigin() : superMethod;
|
||||
relevantElement = JetPsiUtil.ascendIfPropertyAccessor(relevantElement);
|
||||
if (ArrayUtilRt.find(ignore, relevantElement) < 0 && !MethodSignatureUtil.isSuperMethod(originalMethod, superMethod)) {
|
||||
return true;
|
||||
@@ -745,8 +747,8 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
|
||||
}
|
||||
|
||||
private static boolean checkPsiMethodEquality(@NotNull PsiMethod method1, @NotNull PsiMethod method2) {
|
||||
if (method1 instanceof JetClsMethod && method2 instanceof JetClsMethod) {
|
||||
return ((JetClsMethod) method1).getOrigin().equals(((JetClsMethod) method2).getOrigin());
|
||||
if (method1 instanceof KotlinLightMethod && method2 instanceof KotlinLightMethod) {
|
||||
return ((KotlinLightMethod) method1).getOrigin().equals(((KotlinLightMethod) method2).getOrigin());
|
||||
}
|
||||
return method1.equals(method2);
|
||||
}
|
||||
@@ -756,8 +758,8 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
|
||||
Collection<PsiMethod> overridingMethods = OverridingMethodsSearch.search(method, true).findAll();
|
||||
overrideLoop:
|
||||
for (PsiMethod overridingMethod : overridingMethods) {
|
||||
PsiElement overridingElement = overridingMethod instanceof JetClsMethod
|
||||
? ((JetClsMethod) overridingMethod).getOrigin()
|
||||
PsiElement overridingElement = overridingMethod instanceof KotlinLightMethod
|
||||
? ((KotlinLightMethod) overridingMethod).getOrigin()
|
||||
: overridingMethod;
|
||||
|
||||
Collection<PsiMethod> currentSuperMethods = new ArrayList<PsiMethod>();
|
||||
@@ -854,8 +856,8 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
|
||||
}
|
||||
|
||||
private static void addParameter(@NotNull PsiMethod method, @NotNull Set<PsiElement> result, int parameterIndex) {
|
||||
if (method instanceof JetClsMethod) {
|
||||
JetDeclaration declaration = ((JetClsMethod) method).getOrigin();
|
||||
if (method instanceof KotlinLightMethod) {
|
||||
JetDeclaration declaration = ((KotlinLightMethod) method).getOrigin();
|
||||
if (declaration instanceof JetNamedFunction) {
|
||||
result.add(((JetNamedFunction) declaration).getValueParameters().get(parameterIndex));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -88,7 +88,7 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
||||
@Override
|
||||
public boolean isReferenceTo(PsiElement element) {
|
||||
PsiElement target = resolve();
|
||||
PsiElement mirrorElement = element instanceof JetClsMethod ? ((JetClsMethod) element).getOrigin() : null;
|
||||
PsiElement mirrorElement = element instanceof KotlinLightMethod ? ((KotlinLightMethod) element).getOrigin() : null;
|
||||
return target == element || (mirrorElement != null && target == mirrorElement) || (target != null && target.getNavigationElement() == element);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
|
||||
public class KotlinDefinitionsSearcher implements QueryExecutor<PsiElement, DefinitionsScopedSearch.SearchParameters> {
|
||||
@Override
|
||||
@@ -116,7 +116,8 @@ public class KotlinDefinitionsSearcher implements QueryExecutor<PsiElement, Defi
|
||||
for (PsiMethod method : accessors) {
|
||||
PsiMethod[] implementations = MethodImplementationsSearch.getMethodImplementations(method, scope);
|
||||
for (PsiMethod implementation : implementations) {
|
||||
PsiElement mirrorElement = implementation instanceof JetClsMethod ? ((JetClsMethod) implementation).getOrigin() : null;
|
||||
PsiElement mirrorElement = implementation instanceof KotlinLightMethod
|
||||
? ((KotlinLightMethod) implementation).getOrigin() : null;
|
||||
if (mirrorElement instanceof JetProperty || mirrorElement instanceof JetParameter) {
|
||||
if (!consumer.process(mirrorElement)) {
|
||||
return false;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import com.intellij.psi.PsiReference
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil
|
||||
import org.jetbrains.jet.plugin.references.JetPsiReference
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||
@@ -43,6 +43,7 @@ import org.jetbrains.jet.asJava.LightClassUtil
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi
|
||||
import org.jetbrains.jet.codegen.PropertyCodegen
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod
|
||||
|
||||
// Navigation element of the resolved reference
|
||||
// For property accessor return enclosing property
|
||||
@@ -161,7 +162,7 @@ fun PsiReference.isPropertyReadOnlyUsage(): Boolean {
|
||||
if (JetUsageTypeProvider.getUsageType(getElement()) == UsageType.READ) return true
|
||||
|
||||
val refTarget = resolve()
|
||||
if (refTarget is JetClsMethod) {
|
||||
if (refTarget is KotlinLightMethod) {
|
||||
val origin = refTarget.getOrigin()
|
||||
val declaration: JetNamedDeclaration? = when (origin) {
|
||||
is JetPropertyAccessor -> origin.getParentByType(javaClass<JetProperty>())
|
||||
|
||||
Reference in New Issue
Block a user