Basic annotations on classes
This commit is contained in:
+8
-18
@@ -6,32 +6,16 @@ import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||
import org.jetbrains.jet.lang.types.TypeConstructorImpl;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -40,6 +24,8 @@ public class MutableClassDescriptorLite extends MutableDeclarationDescriptor imp
|
||||
private ConstructorDescriptor primaryConstructor;
|
||||
private final Set<ConstructorDescriptor> constructors = Sets.newLinkedHashSet();
|
||||
|
||||
private final List<AnnotationDescriptor> annotations = Lists.newArrayList();
|
||||
|
||||
private Map<String, ClassDescriptor> innerClassesAndObjects = Maps.newHashMap();
|
||||
|
||||
private List<TypeParameterDescriptor> typeParameters;
|
||||
@@ -339,4 +325,8 @@ public class MutableClassDescriptorLite extends MutableDeclarationDescriptor imp
|
||||
return visitor.visitClassDescriptor(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnnotationDescriptor> getAnnotations() {
|
||||
return annotations;
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -16,11 +13,6 @@ public abstract class MutableDeclarationDescriptor implements DeclarationDescrip
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnnotationDescriptor> getAnnotations() {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
@@ -54,6 +54,8 @@ public class TypeHierarchyResolver {
|
||||
|
||||
// At this point, there are no loops in the type hierarchy
|
||||
|
||||
resolveAnnotations();
|
||||
|
||||
checkSupertypesForConsistency();
|
||||
// computeSuperclasses();
|
||||
|
||||
@@ -364,6 +366,22 @@ public class TypeHierarchyResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveAnnotations() {
|
||||
AnnotationResolver annotationResolver = new AnnotationResolver(context.getSemanticServices(), context.getTrace());
|
||||
for (Map.Entry<JetClass, MutableClassDescriptor> entry : context.getClasses().entrySet()) {
|
||||
JetClass jetClass = entry.getKey();
|
||||
MutableClassDescriptor descriptor = entry.getValue();
|
||||
JetModifierList modifierList = jetClass.getModifierList();
|
||||
if (modifierList != null) {
|
||||
descriptor.getAnnotations().addAll(annotationResolver.resolveAnnotations(descriptor.getScopeForSupertypeResolution(), modifierList.getAnnotationEntries()));
|
||||
}
|
||||
}
|
||||
for (Map.Entry<JetObjectDeclaration, MutableClassDescriptor> entry : context.getObjects().entrySet()) {
|
||||
JetObjectDeclaration objectDeclaration = entry.getKey();
|
||||
MutableClassDescriptor descriptor = entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSupertypesForConsistency() {
|
||||
for (MutableClassDescriptor mutableClassDescriptor : topologicalOrder) {
|
||||
Multimap<TypeConstructor, TypeProjection> multimap = TypeUtils.buildDeepSubstitutionMultimap(mutableClassDescriptor.getDefaultType());
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// +JDK
|
||||
annotation [java.lang.Deprecated] class my
|
||||
annotation Deprecated class my1
|
||||
Reference in New Issue
Block a user