Support @param and @sparam annotations
This commit is contained in:
@@ -252,7 +252,20 @@ public class FunctionCodegen {
|
|||||||
if (kind == JvmMethodParameterKind.VALUE) {
|
if (kind == JvmMethodParameterKind.VALUE) {
|
||||||
ValueParameterDescriptor parameter = iterator.next();
|
ValueParameterDescriptor parameter = iterator.next();
|
||||||
v.getSerializationBindings().put(INDEX_FOR_VALUE_PARAMETER, parameter, i);
|
v.getSerializationBindings().put(INDEX_FOR_VALUE_PARAMETER, parameter, i);
|
||||||
AnnotationCodegen.forParameter(i, mv, typeMapper).genAnnotations(parameter, parameterSignature.getAsmType());
|
AnnotationCodegen annotationCodegen = AnnotationCodegen.forParameter(i, mv, typeMapper);
|
||||||
|
|
||||||
|
if (functionDescriptor instanceof PropertySetterDescriptor) {
|
||||||
|
PropertyDescriptor propertyDescriptor = ((PropertySetterDescriptor) functionDescriptor).getCorrespondingProperty();
|
||||||
|
Annotated targetedAnnotations = new AnnotatedWithAdditionalAnnotations(null, propertyDescriptor);
|
||||||
|
annotationCodegen.genAnnotations(targetedAnnotations, parameterSignature.getAsmType(), SETTER_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (functionDescriptor instanceof ConstructorDescriptor) {
|
||||||
|
annotationCodegen.genAnnotations(parameter, parameterSignature.getAsmType(), CONSTRUCTOR_PARAMETER);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
annotationCodegen.genAnnotations(parameter, parameterSignature.getAsmType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (kind == JvmMethodParameterKind.RECEIVER) {
|
else if (kind == JvmMethodParameterKind.RECEIVER) {
|
||||||
Annotated annotationHolder = (functionDescriptor instanceof PropertyAccessorDescriptor)
|
Annotated annotationHolder = (functionDescriptor instanceof PropertyAccessorDescriptor)
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_SET_TARGET = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> INAPPLICABLE_SET_TARGET = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_RECEIVER_TARGET = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> INAPPLICABLE_RECEIVER_TARGET = DiagnosticFactory0.create(ERROR);
|
||||||
|
DiagnosticFactory0<PsiElement> INAPPLICABLE_SPARAM_TARGET = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
// Classes and traits
|
// Classes and traits
|
||||||
|
|
||||||
|
|||||||
+1
@@ -131,6 +131,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(INAPPLICABLE_SET_TARGET, "''@set:'' annotations could be applied only to property declarations");
|
MAP.put(INAPPLICABLE_SET_TARGET, "''@set:'' annotations could be applied only to property declarations");
|
||||||
MAP.put(INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE, "Property must be mutable");
|
MAP.put(INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE, "Property must be mutable");
|
||||||
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "''@receiver:'' annotations could be applied only to extension function or extension property declarations");
|
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "''@receiver:'' annotations could be applied only to extension function or extension property declarations");
|
||||||
|
MAP.put(INAPPLICABLE_SPARAM_TARGET, "''@sparam:'' annotations could be applied only to property declarations");
|
||||||
|
|
||||||
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
|
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
|
||||||
MAP.put(ABSTRACT_MODIFIER_IN_TRAIT, "Modifier ''abstract'' is redundant in interface");
|
MAP.put(ABSTRACT_MODIFIER_IN_TRAIT, "Modifier ''abstract'' is redundant in interface");
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public class JetAnnotationUseSiteTarget : JetElementImplStub<KotlinPlaceHolderSt
|
|||||||
JetTokens.GET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_GETTER
|
JetTokens.GET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_GETTER
|
||||||
JetTokens.SET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_SETTER
|
JetTokens.SET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_SETTER
|
||||||
JetTokens.RECEIVER_KEYWORD -> AnnotationUseSiteTarget.RECEIVER
|
JetTokens.RECEIVER_KEYWORD -> AnnotationUseSiteTarget.RECEIVER
|
||||||
|
JetTokens.PARAM_KEYWORD -> AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER
|
||||||
|
JetTokens.SPARAM_KEYWORD -> AnnotationUseSiteTarget.SETTER_PARAMETER
|
||||||
else -> throw IllegalStateException("Unknown annotation target " + node.getText())
|
else -> throw IllegalStateException("Unknown annotation target " + node.getText())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,6 +255,10 @@ public class ModifiersChecker {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SETTER_PARAMETER: {
|
||||||
|
reportIfNotMutableProperty(descriptor, annotation, INAPPLICABLE_SPARAM_TARGET);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -22,7 +22,9 @@ public enum class AnnotationUseSiteTarget(renderName: String? = null) {
|
|||||||
PROPERTY(),
|
PROPERTY(),
|
||||||
PROPERTY_GETTER("get"),
|
PROPERTY_GETTER("get"),
|
||||||
PROPERTY_SETTER("set"),
|
PROPERTY_SETTER("set"),
|
||||||
RECEIVER();
|
RECEIVER(),
|
||||||
|
CONSTRUCTOR_PARAMETER("param"),
|
||||||
|
SETTER_PARAMETER("sparam");
|
||||||
|
|
||||||
public val renderName: String = renderName ?: name().toLowerCase()
|
public val renderName: String = renderName ?: name().toLowerCase()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user