@Nullable private CompileTimeConstant<?> getCompileTimeConstFromReferenceExpression( PsiReferenceExpression value, PostponedTasks taskList) { PsiElement resolveElement = value.resolve(); if (resolveElement instanceof PsiEnumConstant) { PsiElement psiElement = resolveElement.getParent(); if (psiElement instanceof PsiClass) { PsiClass psiClass = (PsiClass) psiElement; String fqName = psiClass.getQualifiedName(); if (fqName == null) { return null; } JetScope scope; ClassDescriptor classDescriptor = classResolver.resolveClass( new FqName(fqName), DescriptorSearchRule.INCLUDE_KOTLIN, taskList); if (classDescriptor == null) { return null; } ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor(); if (classObjectDescriptor == null) { return null; } scope = classObjectDescriptor.getMemberScope(Lists.<TypeProjection>newArrayList()); Name identifier = Name.identifier(((PsiEnumConstant) resolveElement).getName()); Collection<VariableDescriptor> properties = scope.getProperties(identifier); for (VariableDescriptor variableDescriptor : properties) { if (variableDescriptor.getReceiverParameter() == null) { return new EnumValue((PropertyDescriptor) variableDescriptor); } } return null; } } return null; }
@Nullable private CompileTimeConstant<?> getCompileTimeConstFromArrayExpression( FqName annotationFqName, Name valueName, PsiArrayInitializerMemberValue value, PostponedTasks taskList) { PsiAnnotationMemberValue[] initializers = value.getInitializers(); List<CompileTimeConstant<?>> values = getCompileTimeConstantForArrayValues(annotationFqName, valueName, taskList, initializers); ClassDescriptor classDescriptor = classResolver.resolveClass(annotationFqName, DescriptorSearchRule.INCLUDE_KOTLIN, taskList); // TODO: nullability issues ValueParameterDescriptor valueParameterDescriptor = DescriptorResolverUtils.getValueParameterDescriptorForAnnotationParameter( valueName, classDescriptor); if (valueParameterDescriptor == null) { return null; } JetType expectedArrayType = valueParameterDescriptor.getType(); return new ArrayValue(values, expectedArrayType); }