checkModifiersAndAnnotationsInPackageDirectives() moved to DeclarationsChecker
This commit is contained in:
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.*;
|
import com.google.common.collect.*;
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.openapi.util.Pair;
|
import com.intellij.openapi.util.Pair;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
@@ -35,7 +34,6 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
|||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -84,7 +82,6 @@ public class DeclarationResolver {
|
|||||||
|
|
||||||
|
|
||||||
public void process(@NotNull TopDownAnalysisContext c) {
|
public void process(@NotNull TopDownAnalysisContext c) {
|
||||||
checkModifiersAndAnnotationsInPackageDirectives(c);
|
|
||||||
resolveAnnotationConstructors(c);
|
resolveAnnotationConstructors(c);
|
||||||
resolveConstructorHeaders(c);
|
resolveConstructorHeaders(c);
|
||||||
resolveAnnotationStubsOnClassesAndConstructors(c);
|
resolveAnnotationStubsOnClassesAndConstructors(c);
|
||||||
@@ -95,31 +92,6 @@ public class DeclarationResolver {
|
|||||||
checkRedeclarationsInInnerClassNames(c);
|
checkRedeclarationsInInnerClassNames(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkModifiersAndAnnotationsInPackageDirectives(@NotNull TopDownAnalysisContext c) {
|
|
||||||
for (JetFile file : c.getFiles()) {
|
|
||||||
JetPackageDirective packageDirective = file.getPackageDirective();
|
|
||||||
if (packageDirective == null) continue;
|
|
||||||
|
|
||||||
PsiElement firstChild = packageDirective.getFirstChild();
|
|
||||||
if (!(firstChild instanceof JetModifierList)) continue;
|
|
||||||
JetModifierList modifierList = (JetModifierList) firstChild;
|
|
||||||
|
|
||||||
for (JetAnnotationEntry annotationEntry : modifierList.getAnnotationEntries()) {
|
|
||||||
JetConstructorCalleeExpression calleeExpression = annotationEntry.getCalleeExpression();
|
|
||||||
if (calleeExpression != null) {
|
|
||||||
JetReferenceExpression reference = calleeExpression.getConstructorReferenceExpression();
|
|
||||||
if (reference != null) {
|
|
||||||
trace.report(UNRESOLVED_REFERENCE.on(reference, reference));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ASTNode node : modifierList.getModifierNodes()) {
|
|
||||||
trace.report(ILLEGAL_MODIFIER.on(node.getPsi(), (JetKeywordToken) node.getElementType()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resolveAnnotationConstructors(@NotNull TopDownAnalysisContext c) {
|
private void resolveAnnotationConstructors(@NotNull TopDownAnalysisContext c) {
|
||||||
for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry : c.getClasses().entrySet()) {
|
for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry : c.getClasses().entrySet()) {
|
||||||
JetClassOrObject classOrObject = entry.getKey();
|
JetClassOrObject classOrObject = entry.getKey();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve;
|
|||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||||
@@ -47,6 +48,10 @@ public class DeclarationsChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process(@NotNull BodiesResolveContext bodiesResolveContext) {
|
public void process(@NotNull BodiesResolveContext bodiesResolveContext) {
|
||||||
|
for (JetFile file : bodiesResolveContext.getFiles()) {
|
||||||
|
checkModifiersAndAnnotationsInPackageDirective(file);
|
||||||
|
}
|
||||||
|
|
||||||
Map<JetClassOrObject, ClassDescriptorWithResolutionScopes> classes = bodiesResolveContext.getClasses();
|
Map<JetClassOrObject, ClassDescriptorWithResolutionScopes> classes = bodiesResolveContext.getClasses();
|
||||||
for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry : classes.entrySet()) {
|
for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry : classes.entrySet()) {
|
||||||
JetClassOrObject classOrObject = entry.getKey();
|
JetClassOrObject classOrObject = entry.getKey();
|
||||||
@@ -96,6 +101,29 @@ public class DeclarationsChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkModifiersAndAnnotationsInPackageDirective(JetFile file) {
|
||||||
|
JetPackageDirective packageDirective = file.getPackageDirective();
|
||||||
|
if (packageDirective == null) return;
|
||||||
|
|
||||||
|
PsiElement firstChild = packageDirective.getFirstChild();
|
||||||
|
if (!(firstChild instanceof JetModifierList)) return;
|
||||||
|
JetModifierList modifierList = (JetModifierList) firstChild;
|
||||||
|
|
||||||
|
for (JetAnnotationEntry annotationEntry : modifierList.getAnnotationEntries()) {
|
||||||
|
JetConstructorCalleeExpression calleeExpression = annotationEntry.getCalleeExpression();
|
||||||
|
if (calleeExpression != null) {
|
||||||
|
JetReferenceExpression reference = calleeExpression.getConstructorReferenceExpression();
|
||||||
|
if (reference != null) {
|
||||||
|
trace.report(UNRESOLVED_REFERENCE.on(reference, reference));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ASTNode node : modifierList.getModifierNodes()) {
|
||||||
|
trace.report(ILLEGAL_MODIFIER.on(node.getPsi(), (JetKeywordToken) node.getElementType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkSupertypesForConsistency(@NotNull ClassDescriptor classDescriptor) {
|
private void checkSupertypesForConsistency(@NotNull ClassDescriptor classDescriptor) {
|
||||||
Multimap<TypeConstructor, TypeProjection> multimap = SubstitutionUtils
|
Multimap<TypeConstructor, TypeProjection> multimap = SubstitutionUtils
|
||||||
.buildDeepSubstitutionMultimap(classDescriptor.getDefaultType());
|
.buildDeepSubstitutionMultimap(classDescriptor.getDefaultType());
|
||||||
|
|||||||
Reference in New Issue
Block a user