introduce constants for cases when annotations not present
This commit is contained in:
+3
-1
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
*/
|
||||
public class JetClassAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
public static final JetClassAnnotation NULL_ANNOTATION = new JetClassAnnotation(null);
|
||||
private String signature;
|
||||
|
||||
public JetClassAnnotation(@Nullable PsiAnnotation psiAnnotation) {
|
||||
@@ -47,6 +48,7 @@ public class JetClassAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
@NotNull
|
||||
public static JetClassAnnotation get(PsiClass psiClass) {
|
||||
return new JetClassAnnotation(JavaDescriptorResolver.findAnnotation(psiClass, JvmStdlibNames.JET_CLASS.getFqName().getFqName()));
|
||||
final PsiAnnotation annotation = JavaDescriptorResolver.findAnnotation(psiClass, JvmStdlibNames.JET_CLASS.getFqName().getFqName());
|
||||
return annotation != null ? new JetClassAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -27,6 +27,8 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
*/
|
||||
public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
public static final JetConstructorAnnotation NULL_ANNOTATION = new JetConstructorAnnotation(null);
|
||||
|
||||
public JetConstructorAnnotation(@Nullable PsiAnnotation psiAnnotation) {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
@@ -46,6 +48,8 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
|
||||
}
|
||||
|
||||
public static JetConstructorAnnotation get(PsiMethod constructor) {
|
||||
return new JetConstructorAnnotation(JavaDescriptorResolver.findAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName()));
|
||||
final PsiAnnotation annotation =
|
||||
JavaDescriptorResolver.findAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName());
|
||||
return annotation != null ? new JetConstructorAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
*/
|
||||
public class JetMethodAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
public static final JetMethodAnnotation NULL_ANNOTATION = new JetMethodAnnotation(null);
|
||||
private String typeParameters;
|
||||
private String returnType;
|
||||
private String propertyType;
|
||||
@@ -68,6 +69,8 @@ public class JetMethodAnnotation extends PsiAnnotationWithFlags {
|
||||
}
|
||||
|
||||
public static JetMethodAnnotation get(PsiMethod psiMethod) {
|
||||
return new JetMethodAnnotation(JavaDescriptorResolver.findAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName()));
|
||||
final PsiAnnotation annotation =
|
||||
JavaDescriptorResolver.findAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName());
|
||||
return annotation != null ? new JetMethodAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -27,7 +27,9 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
|
||||
|
||||
|
||||
public static final JetTypeParameterAnnotation NULL_ANNOTATION = new JetTypeParameterAnnotation(null);
|
||||
|
||||
protected JetTypeParameterAnnotation(@Nullable PsiAnnotation psiAnnotation) {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
@@ -38,7 +40,8 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
|
||||
|
||||
@NotNull
|
||||
public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) {
|
||||
return new JetTypeParameterAnnotation(
|
||||
JavaDescriptorResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName()));
|
||||
final PsiAnnotation annotation =
|
||||
JavaDescriptorResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName());
|
||||
return annotation != null ? new JetTypeParameterAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -28,7 +28,9 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
|
||||
|
||||
|
||||
public static final JetValueParameterAnnotation NULL_ANNOTATION = new JetValueParameterAnnotation(null);
|
||||
|
||||
public JetValueParameterAnnotation(@Nullable PsiAnnotation psiAnnotation) {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
@@ -76,7 +78,8 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
|
||||
}
|
||||
|
||||
public static JetValueParameterAnnotation get(PsiParameter psiParameter) {
|
||||
return new JetValueParameterAnnotation(
|
||||
JavaDescriptorResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName()));
|
||||
final PsiAnnotation annotation =
|
||||
JavaDescriptorResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName());
|
||||
return annotation != null ? new JetValueParameterAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user