Support @property annotations

This commit is contained in:
Yan Zhulanow
2015-07-16 18:36:29 +03:00
parent b1a28bcc6a
commit 93579564c8
6 changed files with 17 additions and 5 deletions
@@ -133,6 +133,7 @@ public interface Errors {
DiagnosticFactory0<PsiElement> INAPPLICABLE_FIELD_TARGET = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INAPPLICABLE_FIELD_TARGET_NO_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INAPPLICABLE_PROPERTY_TARGET = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INAPPLICABLE_GET_TARGET = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INAPPLICABLE_SET_TARGET = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE = DiagnosticFactory0.create(ERROR);
@@ -126,6 +126,7 @@ public class DefaultErrorMessages {
MAP.put(INAPPLICABLE_FIELD_TARGET, "''@field:'' annotations could be applied only to property declarations");
MAP.put(INAPPLICABLE_FIELD_TARGET_NO_BACKING_FIELD, "Property has neither a backing field nor a delegate");
MAP.put(INAPPLICABLE_PROPERTY_TARGET, "''@property:'' annotations could be applied only to property declarations");
MAP.put(INAPPLICABLE_GET_TARGET, "''@get:'' 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");
@@ -38,6 +38,7 @@ public class JetAnnotationUseSiteTarget : JetElementImplStub<KotlinPlaceHolderSt
return when (node.getElementType()) {
JetTokens.FIELD_KEYWORD -> AnnotationUseSiteTarget.FIELD
JetTokens.FILE_KEYWORD -> AnnotationUseSiteTarget.FILE
JetTokens.PROPERTY_KEYWORD -> AnnotationUseSiteTarget.PROPERTY
JetTokens.GET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_GETTER
JetTokens.SET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_SETTER
else -> throw IllegalStateException("Unknown annotation target " + node.getText())
@@ -234,6 +234,9 @@ public class ModifiersChecker {
break;
case FILE:
throw new IllegalArgumentException("@file annotations are not allowed here");
case PROPERTY:
reportIfNotPropertyDescriptor(descriptor, annotation, INAPPLICABLE_PROPERTY_TARGET);
break;
case PROPERTY_GETTER:
reportIfNotPropertyDescriptor(descriptor, annotation, INAPPLICABLE_GET_TARGET);
break;