jvmName should be applicable to FILE.
Get jvmName from Annotations (JetFile is not Annotated, since it is a part of AST hierarchy, and there is no corresponding descriptor; however, there is a standard way to obtain Annotations for JetFile, which is exactly what we need, and what Annotated provides).
This commit is contained in:
committed by
Michael Bogdanov
parent
b1b845d44d
commit
0fa6e0730a
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.FunctionExpressionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
@@ -561,8 +562,8 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getJvmName(@NotNull Annotated descriptor) {
|
||||
AnnotationDescriptor jvmNameAnnotation = getJvmNameAnnotation(descriptor);
|
||||
public static String getJvmName(@NotNull Annotations annotations) {
|
||||
AnnotationDescriptor jvmNameAnnotation = getJvmNameAnnotation(annotations);
|
||||
if (jvmNameAnnotation == null) return null;
|
||||
|
||||
Map<ValueParameterDescriptor, ConstantValue<?>> arguments = jvmNameAnnotation.getAllValueArguments();
|
||||
@@ -574,14 +575,25 @@ public class DescriptorUtils {
|
||||
return ((StringValue) name).getValue();
|
||||
}
|
||||
|
||||
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotated descriptor) {
|
||||
AnnotationDescriptor jvmNameAnnotation = descriptor.getAnnotations().findAnnotation(JVM_NAME);
|
||||
@Nullable
|
||||
public static String getJvmName(@NotNull Annotated annotated) {
|
||||
return getJvmName(annotated.getAnnotations());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotations annotations) {
|
||||
AnnotationDescriptor jvmNameAnnotation = annotations.findAnnotation(JVM_NAME);
|
||||
if (jvmNameAnnotation == null) {
|
||||
jvmNameAnnotation = descriptor.getAnnotations().findAnnotation(PLATFORM_NAME);
|
||||
jvmNameAnnotation = annotations.findAnnotation(PLATFORM_NAME);
|
||||
}
|
||||
return jvmNameAnnotation;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotated annotated) {
|
||||
return getJvmNameAnnotation(annotated.getAnnotations());
|
||||
}
|
||||
|
||||
private static void getSubPackagesFqNames(PackageViewDescriptor packageView, Set<FqName> result) {
|
||||
FqName fqName = packageView.getFqName();
|
||||
if (!fqName.isRoot()) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public annotation class JvmStatic
|
||||
* for more information.
|
||||
* @property name the name of the element.
|
||||
*/
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@MustBeDocumented
|
||||
public annotation class JvmName(public val name: String)
|
||||
|
||||
Reference in New Issue
Block a user