JS: use external modifier instead of @native annotation
This commit is contained in:
@@ -83,18 +83,24 @@ public final class AnnotationsUtils {
|
||||
|
||||
@Nullable
|
||||
public static String getNameForAnnotatedObject(@NotNull DeclarationDescriptor descriptor) {
|
||||
String defaultJsName = getJsName(descriptor);
|
||||
|
||||
for (PredefinedAnnotation annotation : PredefinedAnnotation.Companion.getWITH_CUSTOM_NAME()) {
|
||||
if (!hasAnnotationOrInsideAnnotatedClass(descriptor, annotation)) {
|
||||
continue;
|
||||
}
|
||||
String name = getNameForAnnotatedObject(descriptor, annotation);
|
||||
if (name == null) {
|
||||
name = getJsName(descriptor);
|
||||
name = defaultJsName;
|
||||
}
|
||||
return name != null ? name : descriptor.getName().asString();
|
||||
}
|
||||
|
||||
return getJsName(descriptor);
|
||||
if (defaultJsName == null && isEffectivelyExternal(descriptor)) {
|
||||
return descriptor.getName().asString();
|
||||
}
|
||||
|
||||
return defaultJsName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -112,7 +118,7 @@ public final class AnnotationsUtils {
|
||||
}
|
||||
|
||||
public static boolean isNativeObject(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (hasAnnotationOrInsideAnnotatedClass(descriptor, PredefinedAnnotation.NATIVE)) return true;
|
||||
if (hasAnnotationOrInsideAnnotatedClass(descriptor, PredefinedAnnotation.NATIVE) || isEffectivelyExternal(descriptor)) return true;
|
||||
|
||||
if (descriptor instanceof PropertyAccessorDescriptor) {
|
||||
PropertyAccessorDescriptor accessor = (PropertyAccessorDescriptor) descriptor;
|
||||
@@ -126,6 +132,13 @@ public final class AnnotationsUtils {
|
||||
return isNativeObject(descriptor) && DescriptorUtils.isInterface(descriptor);
|
||||
}
|
||||
|
||||
private static boolean isEffectivelyExternal(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof MemberDescriptor && ((MemberDescriptor) descriptor).isExternal()) return true;
|
||||
|
||||
ClassDescriptor containingClass = DescriptorUtils.getContainingClass(descriptor);
|
||||
return containingClass != null && isEffectivelyExternal(containingClass);
|
||||
}
|
||||
|
||||
public static boolean isLibraryObject(@NotNull DeclarationDescriptor descriptor) {
|
||||
return hasAnnotationOrInsideAnnotatedClass(descriptor, PredefinedAnnotation.LIBRARY);
|
||||
}
|
||||
@@ -151,6 +164,7 @@ public final class AnnotationsUtils {
|
||||
|
||||
public static boolean isPredefinedObject(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof MemberDescriptor && ((MemberDescriptor) descriptor).isPlatform()) return true;
|
||||
if (isEffectivelyExternal(descriptor)) return true;
|
||||
|
||||
for (PredefinedAnnotation annotation : PredefinedAnnotation.values()) {
|
||||
if (hasAnnotationOrInsideAnnotatedClass(descriptor, annotation)) {
|
||||
|
||||
Reference in New Issue
Block a user