Make room for laziness in the Annotations interface
This commit is contained in:
@@ -149,7 +149,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
// Annotations on properties without backing fields are stored in bytecode on an empty synthetic method. This way they're still
|
// Annotations on properties without backing fields are stored in bytecode on an empty synthetic method. This way they're still
|
||||||
// accessible via reflection, and 'deprecated' and 'private' flags prevent this method from being called accidentally
|
// accessible via reflection, and 'deprecated' and 'private' flags prevent this method from being called accidentally
|
||||||
private void generateSyntheticMethodIfNeeded(@NotNull PropertyDescriptor descriptor) {
|
private void generateSyntheticMethodIfNeeded(@NotNull PropertyDescriptor descriptor) {
|
||||||
if (descriptor.getAnnotations().getAnnotationDescriptors().isEmpty()) return;
|
if (descriptor.getAnnotations().isEmpty()) return;
|
||||||
|
|
||||||
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
|
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
|
||||||
Type receiverAsmType = receiver == null ? null : typeMapper.mapType(receiver.getType());
|
Type receiverAsmType = receiver == null ? null : typeMapper.mapType(receiver.getType());
|
||||||
|
|||||||
+1
-1
@@ -431,7 +431,7 @@ public class DescriptorSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasAnnotations(Annotated descriptor) {
|
private static boolean hasAnnotations(Annotated descriptor) {
|
||||||
return !descriptor.getAnnotations().getAnnotationDescriptors().isEmpty();
|
return !descriptor.getAnnotations().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class DeclarationResolver {
|
|||||||
if (modifierList != null) {
|
if (modifierList != null) {
|
||||||
MutableClassDescriptor descriptor = entry.getValue();
|
MutableClassDescriptor descriptor = entry.getValue();
|
||||||
descriptor.addAnnotations(annotationResolver.resolveAnnotationsWithoutArguments(
|
descriptor.addAnnotations(annotationResolver.resolveAnnotationsWithoutArguments(
|
||||||
descriptor.getScopeForSupertypeResolution(), modifierList, trace).getAnnotationDescriptors());
|
descriptor.getScopeForSupertypeResolution(), modifierList, trace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-9
@@ -17,28 +17,23 @@
|
|||||||
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.ReadOnly;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface Annotations extends Iterable<AnnotationDescriptor> {
|
public interface Annotations extends Iterable<AnnotationDescriptor> {
|
||||||
Annotations EMPTY = new Annotations() {
|
Annotations EMPTY = new Annotations() {
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public List<AnnotationDescriptor> getAnnotationDescriptors() {
|
public boolean isEmpty() {
|
||||||
return Collections.emptyList();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<AnnotationDescriptor> iterator() {
|
public Iterator<AnnotationDescriptor> iterator() {
|
||||||
return getAnnotationDescriptors().iterator();
|
return Collections.<AnnotationDescriptor>emptyList().iterator();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@NotNull
|
boolean isEmpty();
|
||||||
@ReadOnly
|
|
||||||
List<AnnotationDescriptor> getAnnotationDescriptors();
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -29,11 +29,15 @@ public class AnnotationsImpl implements Annotations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
|
||||||
public List<AnnotationDescriptor> getAnnotationDescriptors() {
|
public List<AnnotationDescriptor> getAnnotationDescriptors() {
|
||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return getAnnotationDescriptors().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<AnnotationDescriptor> iterator() {
|
public Iterator<AnnotationDescriptor> iterator() {
|
||||||
|
|||||||
+10
-3
@@ -39,7 +39,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
|
public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
|
||||||
|
|
||||||
private Annotations annotations = new AnnotationsImpl(new ArrayList<AnnotationDescriptor>(0));
|
private Annotations annotations;
|
||||||
|
|
||||||
private List<TypeParameterDescriptor> typeParameters;
|
private List<TypeParameterDescriptor> typeParameters;
|
||||||
private Collection<JetType> supertypes = Lists.newArrayList();
|
private Collection<JetType> supertypes = Lists.newArrayList();
|
||||||
@@ -183,6 +183,9 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Annotations getAnnotations() {
|
public Annotations getAnnotations() {
|
||||||
|
if (annotations == null) {
|
||||||
|
annotations = new AnnotationsImpl(new ArrayList<AnnotationDescriptor>(0));
|
||||||
|
}
|
||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,8 +193,12 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
|
|||||||
this.annotations = annotations;
|
this.annotations = annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAnnotations(@NotNull List<AnnotationDescriptor> annotationDescriptors) {
|
public void addAnnotations(@NotNull Iterable<AnnotationDescriptor> annotationDescriptors) {
|
||||||
this.annotations.getAnnotationDescriptors().addAll(annotationDescriptors);
|
|
||||||
|
AnnotationsImpl annotationsImpl = (AnnotationsImpl) getAnnotations();
|
||||||
|
for (AnnotationDescriptor annotationDescriptor : annotationDescriptors) {
|
||||||
|
annotationsImpl.getAnnotationDescriptors().add(annotationDescriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PackageLikeBuilder builder = null;
|
private PackageLikeBuilder builder = null;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.di.InjectorForBodyResolve;
|
import org.jetbrains.jet.di.InjectorForBodyResolve;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.*;
|
import org.jetbrains.jet.lang.resolve.*;
|
||||||
@@ -216,7 +217,9 @@ public class ResolveElementCache {
|
|||||||
Annotated descriptor = analyzer.resolveToDescriptor(declaration);
|
Annotated descriptor = analyzer.resolveToDescriptor(declaration);
|
||||||
|
|
||||||
// Activate annotation resolving
|
// Activate annotation resolving
|
||||||
descriptor.getAnnotations().getAnnotationDescriptors();
|
for (AnnotationDescriptor annotationDescriptor : descriptor.getAnnotations()) {
|
||||||
|
// do nothing, all we need is iteration
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user