Annotations.findAnnotation() added
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
package org.jetbrains.jet.lang.descriptors.annotations;
|
package org.jetbrains.jet.lang.descriptors.annotations;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -28,6 +30,12 @@ public interface Annotations extends Iterable<AnnotationDescriptor> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public AnnotationDescriptor findAnnotation(@NotNull FqName fqName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<AnnotationDescriptor> iterator() {
|
public Iterator<AnnotationDescriptor> iterator() {
|
||||||
@@ -36,4 +44,7 @@ public interface Annotations extends Iterable<AnnotationDescriptor> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
boolean isEmpty();
|
boolean isEmpty();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
AnnotationDescriptor findAnnotation(@NotNull FqName fqName);
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -17,6 +17,11 @@
|
|||||||
package org.jetbrains.jet.lang.descriptors.annotations;
|
package org.jetbrains.jet.lang.descriptors.annotations;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -38,6 +43,18 @@ public class AnnotationsImpl implements Annotations {
|
|||||||
return getAnnotationDescriptors().isEmpty();
|
return getAnnotationDescriptors().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public AnnotationDescriptor findAnnotation(@NotNull FqName fqName) {
|
||||||
|
for (AnnotationDescriptor annotation : annotations) {
|
||||||
|
ClassifierDescriptor descriptor = annotation.getType().getConstructor().getDeclarationDescriptor();
|
||||||
|
if (descriptor instanceof ClassDescriptor && fqName.toUnsafe().equals(DescriptorUtils.getFqName(descriptor))) {
|
||||||
|
return annotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<AnnotationDescriptor> iterator() {
|
public Iterator<AnnotationDescriptor> iterator() {
|
||||||
|
|||||||
Reference in New Issue
Block a user