@NotNull public KotlinType getEnumType(@NotNull KotlinType argument) { Variance projectionType = Variance.INVARIANT; List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); return KotlinTypeImpl.create(Annotations.Companion.getEMPTY(), getEnum(), false, types); }
@NotNull public static List<ValueParameterDescriptor> getValueParameters( @NotNull FunctionDescriptor functionDescriptor, @NotNull KotlinType type) { assert isFunctionOrExtensionFunctionType(type); List<TypeProjection> parameterTypes = getParameterTypeProjectionsFromFunctionType(type); List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(parameterTypes.size()); for (int i = 0; i < parameterTypes.size(); i++) { TypeProjection parameterType = parameterTypes.get(i); ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl( functionDescriptor, null, i, Annotations.Companion.getEMPTY(), Name.identifier("p" + (i + 1)), parameterType.getType(), /* declaresDefaultValue = */ false, /* isCrossinline = */ false, /* isNoinline = */ false, null, SourceElement.NO_SOURCE); valueParameters.add(valueParameterDescriptor); } return valueParameters; }
private static boolean containsAnnotation( DeclarationDescriptor descriptor, FqName annotationClassFqName) { DeclarationDescriptor original = descriptor.getOriginal(); Annotations annotations = original.getAnnotations(); if (annotations.findAnnotation(annotationClassFqName) != null) return true; AnnotationUseSiteTarget associatedUseSiteTarget = AnnotationUseSiteTarget.Companion.getAssociatedUseSiteTarget(descriptor); if (associatedUseSiteTarget != null) { if (Annotations.Companion.findUseSiteTargetedAnnotation( annotations, associatedUseSiteTarget, annotationClassFqName) != null) { return true; } } return false; }