@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; }
@Override public void recordField(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor) { PsiField psiField = ((JavaFieldImpl) field).getPsi(); trace.record(VARIABLE, psiField, descriptor); if (AnnotationUtils.isPropertyCompileTimeConstant(descriptor)) { PsiExpression initializer = psiField.getInitializer(); Object evaluatedExpression = JavaConstantExpressionEvaluator.computeConstantExpression(initializer, false); if (evaluatedExpression != null) { CompileTimeConstant<?> constant = JavaAnnotationArgumentResolver.resolveCompileTimeConstantValue( evaluatedExpression, descriptor.getType()); if (constant != null) { trace.record(COMPILE_TIME_INITIALIZER, descriptor, constant); } } } }