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.*;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
|
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.AnonymousFunctionDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.FunctionExpressionDescriptor;
|
import org.jetbrains.kotlin.descriptors.impl.FunctionExpressionDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||||
@@ -561,8 +562,8 @@ public class DescriptorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getJvmName(@NotNull Annotated descriptor) {
|
public static String getJvmName(@NotNull Annotations annotations) {
|
||||||
AnnotationDescriptor jvmNameAnnotation = getJvmNameAnnotation(descriptor);
|
AnnotationDescriptor jvmNameAnnotation = getJvmNameAnnotation(annotations);
|
||||||
if (jvmNameAnnotation == null) return null;
|
if (jvmNameAnnotation == null) return null;
|
||||||
|
|
||||||
Map<ValueParameterDescriptor, ConstantValue<?>> arguments = jvmNameAnnotation.getAllValueArguments();
|
Map<ValueParameterDescriptor, ConstantValue<?>> arguments = jvmNameAnnotation.getAllValueArguments();
|
||||||
@@ -574,14 +575,25 @@ public class DescriptorUtils {
|
|||||||
return ((StringValue) name).getValue();
|
return ((StringValue) name).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotated descriptor) {
|
@Nullable
|
||||||
AnnotationDescriptor jvmNameAnnotation = descriptor.getAnnotations().findAnnotation(JVM_NAME);
|
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) {
|
if (jvmNameAnnotation == null) {
|
||||||
jvmNameAnnotation = descriptor.getAnnotations().findAnnotation(PLATFORM_NAME);
|
jvmNameAnnotation = annotations.findAnnotation(PLATFORM_NAME);
|
||||||
}
|
}
|
||||||
return jvmNameAnnotation;
|
return jvmNameAnnotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotated annotated) {
|
||||||
|
return getJvmNameAnnotation(annotated.getAnnotations());
|
||||||
|
}
|
||||||
|
|
||||||
private static void getSubPackagesFqNames(PackageViewDescriptor packageView, Set<FqName> result) {
|
private static void getSubPackagesFqNames(PackageViewDescriptor packageView, Set<FqName> result) {
|
||||||
FqName fqName = packageView.getFqName();
|
FqName fqName = packageView.getFqName();
|
||||||
if (!fqName.isRoot()) {
|
if (!fqName.isRoot()) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public annotation class JvmStatic
|
|||||||
* for more information.
|
* for more information.
|
||||||
* @property name the name of the element.
|
* @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)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
@MustBeDocumented
|
@MustBeDocumented
|
||||||
public annotation class JvmName(public val name: String)
|
public annotation class JvmName(public val name: String)
|
||||||
|
|||||||
Reference in New Issue
Block a user