@NotNull public List<AnnotationDescriptor> resolveAnnotations(@NotNull JavaAnnotationOwner owner) { PostponedTasks postponedTasks = new PostponedTasks(); List<AnnotationDescriptor> annotations = resolveAnnotations(owner, postponedTasks); postponedTasks.performTasks(); return annotations; }
@Nullable public AnnotationDescriptor resolveAnnotation( @NotNull JavaAnnotation javaAnnotation, @NotNull PostponedTasks postponedTasks) { final AnnotationDescriptor annotation = new AnnotationDescriptor(); FqName fqName = javaAnnotation.getFqName(); if (fqName == null) { return null; } // Don't process internal jet annotations and jetbrains NotNull annotations if (fqName.asString().startsWith("jet.runtime.typeinfo.") || fqName.equals(JETBRAINS_NOT_NULL_ANNOTATION) || fqName.equals(JvmAnnotationNames.KOTLIN_CLASS) || fqName.equals(JvmAnnotationNames.KOTLIN_PACKAGE)) { return null; } AnnotationDescriptor mappedClassDescriptor = JavaToKotlinClassMap.getInstance().mapToAnnotationClass(fqName); if (mappedClassDescriptor != null) { return mappedClassDescriptor; } final ClassDescriptor annotationClass = classResolver.resolveClass(fqName, INCLUDE_KOTLIN_SOURCES, postponedTasks); if (annotationClass == null) { return null; } postponedTasks.addTask( new Runnable() { @Override public void run() { annotation.setAnnotationType(annotationClass.getDefaultType()); } }); for (JavaAnnotationArgument argument : javaAnnotation.getArguments()) { CompileTimeConstant value = argumentResolver.resolveAnnotationArgument(fqName, argument, postponedTasks); if (value == null) continue; Name name = argument.getName(); ValueParameterDescriptor descriptor = DescriptorResolverUtils.getAnnotationParameterByName( name == null ? DEFAULT_ANNOTATION_MEMBER_NAME : name, annotationClass); if (descriptor != null) { annotation.setValueArgument(descriptor, value); } } return annotation; }