Changed naming algorithm of accessor name generation: "isXXX" and "kClass" cases affected
This commit is contained in:
@@ -40,8 +40,10 @@ public final class JvmAbi {
|
||||
public static final String TRAIT_IMPL_SUFFIX = "$" + TRAIT_IMPL_CLASS_NAME;
|
||||
|
||||
public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default";
|
||||
public static final String GETTER_PREFIX = "get";
|
||||
public static final String SETTER_PREFIX = "set";
|
||||
|
||||
private static final String GET_PREFIX = "get";
|
||||
private static final String IS_PREFIX = "is";
|
||||
private static final String SET_PREFIX = "set";
|
||||
|
||||
public static final String DELEGATED_PROPERTY_NAME_SUFFIX = "$delegate";
|
||||
public static final String PROPERTY_METADATA_ARRAY_NAME = "$propertyMetadata";
|
||||
@@ -65,21 +67,34 @@ public final class JvmAbi {
|
||||
return isDelegated ? propertyName.asString() + DELEGATED_PROPERTY_NAME_SUFFIX : propertyName.asString();
|
||||
}
|
||||
|
||||
public static boolean isGetterName(@NotNull String name) {
|
||||
return name.startsWith(GET_PREFIX) || name.startsWith(IS_PREFIX);
|
||||
}
|
||||
|
||||
public static boolean isSetterName(@NotNull String name) {
|
||||
return name.startsWith(SET_PREFIX);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getterName(@NotNull String propertyName) {
|
||||
return GETTER_PREFIX + capitalizeWithJavaBeanConvention(propertyName);
|
||||
return startsWithIsPrefix(propertyName)
|
||||
? propertyName
|
||||
: GET_PREFIX + KotlinPackage.capitalize(propertyName);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String setterName(@NotNull String propertyName) {
|
||||
return SETTER_PREFIX + capitalizeWithJavaBeanConvention(propertyName);
|
||||
return startsWithIsPrefix(propertyName)
|
||||
? SET_PREFIX + propertyName.substring(IS_PREFIX.length())
|
||||
: SET_PREFIX + KotlinPackage.capitalize(propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.util.text.StringUtil#capitalizeWithJavaBeanConvention(String)
|
||||
*/
|
||||
@NotNull
|
||||
private static String capitalizeWithJavaBeanConvention(@NotNull String s) {
|
||||
return s.length() > 1 && Character.isUpperCase(s.charAt(1)) ? s : KotlinPackage.capitalize(s);
|
||||
private static boolean startsWithIsPrefix(String name) {
|
||||
if (!name.startsWith(IS_PREFIX)) return false;
|
||||
if (name.length() == IS_PREFIX.length()) return false;
|
||||
char c = name.charAt(IS_PREFIX.length());
|
||||
return !Character.isLowerCase(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ class LazyJavaTypeResolver(
|
||||
|
||||
private fun mapKotlinClass(fqName: FqName): ClassDescriptor? {
|
||||
if (attr.isForAnnotationParameter && fqName == JAVA_LANG_CLASS_FQ_NAME) {
|
||||
return c.reflectionTypes.kClass
|
||||
return c.reflectionTypes.TEMP_kClass
|
||||
}
|
||||
|
||||
val javaToKotlin = JavaToKotlinClassMap.INSTANCE
|
||||
|
||||
Reference in New Issue
Block a user