Search in sources :

Example 6 with FqNameUnsafe

use of org.jetbrains.kotlin.name.FqNameUnsafe in project kotlin by JetBrains.

the class AnnotationsUtils method isFromNonModuleFile.

public static boolean isFromNonModuleFile(@NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor declaration) {
    for (AnnotationDescriptor annotation : getContainingFileAnnotations(bindingContext, declaration)) {
        DeclarationDescriptor annotationType = annotation.getType().getConstructor().getDeclarationDescriptor();
        if (annotationType == null)
            continue;
        DeclarationDescriptor annotationTypeDescriptor = annotation.getType().getConstructor().getDeclarationDescriptor();
        assert annotationTypeDescriptor != null : "Annotation type should have descriptor: " + annotation.getType();
        FqNameUnsafe fqName = DescriptorUtils.getFqName(annotationTypeDescriptor);
        if (fqName.equals(JS_NON_MODULE_ANNOTATION.toUnsafe())) {
            return true;
        }
    }
    return false;
}
Also used : AnnotationDescriptor(org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor) FqNameUnsafe(org.jetbrains.kotlin.name.FqNameUnsafe)

Example 7 with FqNameUnsafe

use of org.jetbrains.kotlin.name.FqNameUnsafe in project kotlin by JetBrains.

the class AnnotationsUtils method getSingleStringAnnotationArgument.

@Nullable
private static String getSingleStringAnnotationArgument(@NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor declaration, @NotNull FqName annotationFqName) {
    for (AnnotationDescriptor annotation : getContainingFileAnnotations(bindingContext, declaration)) {
        DeclarationDescriptor annotationType = annotation.getType().getConstructor().getDeclarationDescriptor();
        if (annotationType == null)
            continue;
        FqNameUnsafe fqName = DescriptorUtils.getFqName(annotation.getType().getConstructor().getDeclarationDescriptor());
        if (fqName.equals(annotationFqName.toUnsafe())) {
            return extractSingleStringArgument(annotation);
        }
    }
    return null;
}
Also used : AnnotationDescriptor(org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor) FqNameUnsafe(org.jetbrains.kotlin.name.FqNameUnsafe) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FqNameUnsafe (org.jetbrains.kotlin.name.FqNameUnsafe)7 Nullable (org.jetbrains.annotations.Nullable)2 AnnotationDescriptor (org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor)2 KotlinType (org.jetbrains.kotlin.types.KotlinType)2 NotNull (org.jetbrains.annotations.NotNull)1 ClassDescriptor (org.jetbrains.kotlin.descriptors.ClassDescriptor)1 ClassifierDescriptor (org.jetbrains.kotlin.descriptors.ClassifierDescriptor)1 NameSuggestion (org.jetbrains.kotlin.js.naming.NameSuggestion)1 SuggestedName (org.jetbrains.kotlin.js.naming.SuggestedName)1 JavaMethod (org.jetbrains.kotlin.load.java.structure.JavaMethod)1 Name (org.jetbrains.kotlin.name.Name)1 DescriptorUtils.getFqName (org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName)1 Method (org.jetbrains.org.objectweb.asm.commons.Method)1