Move getterName/setterName to JvmAbi

Reuse in RuntimeTypeMapper in reflection
This commit is contained in:
Alexander Udalov
2015-07-09 20:05:44 +03:00
parent 64d8e35d26
commit c62f19ee82
13 changed files with 82 additions and 94 deletions
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.codegen;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,7 +25,6 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
import org.jetbrains.kotlin.resolve.BindingContext;
@@ -491,16 +489,6 @@ public class PropertyCodegen {
}
}
@NotNull
public static String getterName(Name propertyName) {
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
}
@NotNull
public static String setterName(Name propertyName) {
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
}
public void genDelegate(@NotNull PropertyDescriptor delegate, @NotNull PropertyDescriptor delegateTo, @NotNull StackValue field) {
ClassDescriptor toClass = (ClassDescriptor) delegateTo.getContainingDeclaration();
@@ -38,7 +38,10 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeDeclarationsPackage;
import org.jetbrains.kotlin.name.*;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.FqNameUnsafe;
import org.jetbrains.kotlin.name.SpecialNames;
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap;
import org.jetbrains.kotlin.psi.JetExpression;
import org.jetbrains.kotlin.psi.JetFile;
@@ -681,13 +684,13 @@ public class JetTypeMapper {
}
boolean isAccessor = property instanceof AccessorForPropertyDescriptor;
Name propertyName = isAccessor
? Name.identifier(((AccessorForPropertyDescriptor) property).getIndexedAccessorSuffix())
: property.getName();
String propertyName = isAccessor
? ((AccessorForPropertyDescriptor) property).getIndexedAccessorSuffix()
: property.getName().asString();
String accessorName = descriptor instanceof PropertyGetterDescriptor
? PropertyCodegen.getterName(propertyName)
: PropertyCodegen.setterName(propertyName);
? JvmAbi.getterName(propertyName)
: JvmAbi.setterName(propertyName);
return isAccessor ? "access$" + accessorName : accessorName;
}
@@ -290,7 +290,8 @@ public class LightClassUtil {
new Function1<PsiMethod, Boolean>() {
@Override
public Boolean invoke(PsiMethod method) {
return JvmAbi.isAccessorName(method.getName());
String name = method.getName();
return name.startsWith(JvmAbi.GETTER_PREFIX) || name.startsWith(JvmAbi.SETTER_PREFIX);
}
}
);