Few nullable annotations added in *Resolver classes

This commit is contained in:
Pavel V. Talanov
2012-10-10 15:30:04 +04:00
parent a1f23597d2
commit e795eeb3f7
8 changed files with 34 additions and 10 deletions
@@ -50,7 +50,7 @@ public final class DescriptorResolverUtils {
return new PsiClassWrapper(psiClass).getJetClass().isDefined() || psiClass.getName().equals(JvmAbi.PACKAGE_CLASS); return new PsiClassWrapper(psiClass).getJetClass().isDefined() || psiClass.getName().equals(JvmAbi.PACKAGE_CLASS);
} }
public static boolean isInnerEnum(@NotNull PsiClass innerClass, DeclarationDescriptor owner) { public static boolean isInnerEnum(@NotNull PsiClass innerClass, @Nullable DeclarationDescriptor owner) {
if (!innerClass.isEnum()) return false; if (!innerClass.isEnum()) return false;
if (!(owner instanceof ClassDescriptor)) return false; if (!(owner instanceof ClassDescriptor)) return false;
@@ -164,10 +164,12 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
return propertiesResolver.resolveFieldGroup(data); return propertiesResolver.resolveFieldGroup(data);
} }
@Nullable
public ClassDescriptor resolveClass(FqName name, DescriptorSearchRule searchRule, List<Runnable> list) { public ClassDescriptor resolveClass(FqName name, DescriptorSearchRule searchRule, List<Runnable> list) {
return classResolver.resolveClass(name, searchRule, list); return classResolver.resolveClass(name, searchRule, list);
} }
@Nullable
public CompileTimeConstant getCompileTimeConstFromExpression( public CompileTimeConstant getCompileTimeConstFromExpression(
FqName annotationName, FqName annotationName,
Name parameterName, Name parameterName,
@@ -99,6 +99,7 @@ public final class AnnotationResolver {
if (name == null) name = "value"; if (name == null) name = "value";
Name identifier = Name.identifier(name); Name identifier = Name.identifier(name);
assert value != null;
CompileTimeConstant compileTimeConst = CompileTimeConstant compileTimeConst =
javaDescriptorResolver.getCompileTimeConstFromExpression(annotationFqName, identifier, value, taskList); javaDescriptorResolver.getCompileTimeConstFromExpression(annotationFqName, identifier, value, taskList);
if (compileTimeConst != null) { if (compileTimeConst != null) {
@@ -94,6 +94,7 @@ public final class ClassResolver {
return clazz; return clazz;
} }
@Nullable
public ClassDescriptor resolveClass( public ClassDescriptor resolveClass(
@NotNull FqName qualifiedName, @NotNull FqName qualifiedName,
@NotNull DescriptorSearchRule searchRule, @NotNull DescriptorSearchRule searchRule,
@@ -142,7 +142,7 @@ public final class FunctionResolver {
} }
private void resolveNamedGroupFunctions( private void resolveNamedGroupFunctions(
@NotNull ClassOrNamespaceDescriptor owner, PsiClass psiClass, @NotNull ClassOrNamespaceDescriptor owner, @NotNull PsiClass psiClass,
NamedMembers namedMembers, Name methodName, ResolverScopeData scopeData NamedMembers namedMembers, Name methodName, ResolverScopeData scopeData
) { ) {
if (namedMembers.getFunctionDescriptors() != null) { if (namedMembers.getFunctionDescriptors() != null) {
@@ -195,6 +195,7 @@ public final class FunctionResolver {
namedMembers.setFunctionDescriptors(functions); namedMembers.setFunctionDescriptors(functions);
} }
@NotNull
public Set<FunctionDescriptor> resolveFunctionGroup(Name methodName, ResolverScopeData scopeData) { public Set<FunctionDescriptor> resolveFunctionGroup(Name methodName, ResolverScopeData scopeData) {
DescriptorResolverUtils.getResolverScopeData(scopeData); DescriptorResolverUtils.getResolverScopeData(scopeData);
@@ -203,10 +204,14 @@ public final class FunctionResolver {
NamedMembers namedMembers = namedMembersMap.get(methodName); NamedMembers namedMembers = namedMembersMap.get(methodName);
if (namedMembers != null) { if (namedMembers != null) {
resolveNamedGroupFunctions(scopeData.getClassOrNamespaceDescriptor(), scopeData.getPsiClass(), namedMembers, PsiClass psiClass = scopeData.getPsiClass();
assert psiClass != null;
resolveNamedGroupFunctions(scopeData.getClassOrNamespaceDescriptor(), psiClass, namedMembers,
methodName, scopeData); methodName, scopeData);
return namedMembers.getFunctionDescriptors(); Set<FunctionDescriptor> result = namedMembers.getFunctionDescriptors();
assert result != null;
return result;
} }
else { else {
return Collections.emptySet(); return Collections.emptySet();
@@ -261,7 +266,9 @@ public final class FunctionResolver {
for (Map.Entry<Name, NamedMembers> entry : scopeData.getNamedMembersMap().entrySet()) { for (Map.Entry<Name, NamedMembers> entry : scopeData.getNamedMembersMap().entrySet()) {
Name methodName = entry.getKey(); Name methodName = entry.getKey();
NamedMembers namedMembers = entry.getValue(); NamedMembers namedMembers = entry.getValue();
resolveNamedGroupFunctions(scopeData.getClassOrNamespaceDescriptor(), scopeData.getPsiClass(), PsiClass psiClass = scopeData.getPsiClass();
assert psiClass != null;
resolveNamedGroupFunctions(scopeData.getClassOrNamespaceDescriptor(), psiClass,
namedMembers, methodName, scopeData); namedMembers, methodName, scopeData);
functions.addAll(namedMembers.getFunctionDescriptors()); functions.addAll(namedMembers.getFunctionDescriptors());
} }
@@ -86,10 +86,12 @@ public final class NamespaceResolver {
return scopeData.getNamespaceDescriptor(); return scopeData.getNamespaceDescriptor();
} }
@Nullable
public NamespaceDescriptor resolveNamespace(@NotNull FqName qualifiedName) { public NamespaceDescriptor resolveNamespace(@NotNull FqName qualifiedName) {
return resolveNamespace(qualifiedName, DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN); return resolveNamespace(qualifiedName, DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
} }
@Nullable
private NamespaceDescriptorParent resolveParentNamespace(FqName fqName) { private NamespaceDescriptorParent resolveParentNamespace(FqName fqName) {
if (fqName.isRoot()) { if (fqName.isRoot()) {
return FAKE_ROOT_MODULE; return FAKE_ROOT_MODULE;
@@ -20,6 +20,7 @@ import com.google.common.collect.Sets;
import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiClass; import com.intellij.psi.PsiClass;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -61,7 +62,9 @@ public final class PropertiesResolver {
resolveNamedGroupProperties(scopeData.getClassOrNamespaceDescriptor(), scopeData, namedMembers, fieldName, resolveNamedGroupProperties(scopeData.getClassOrNamespaceDescriptor(), scopeData, namedMembers, fieldName,
"class or namespace " + qualifiedName); "class or namespace " + qualifiedName);
return namedMembers.getPropertyDescriptors(); Set<VariableDescriptor> result = namedMembers.getPropertyDescriptors();
assert result != null;
return result;
} }
@NotNull @NotNull
@@ -350,6 +353,7 @@ public final class PropertiesResolver {
return propertyType; return propertyType;
} }
@Nullable
private JetType getReceiverType( private JetType getReceiverType(
PropertyAccessorData characteristicMember, PropertyAccessorData characteristicMember,
TypeVariableResolver typeVariableResolverForPropertyInternals TypeVariableResolver typeVariableResolverForPropertyInternals
@@ -426,7 +430,7 @@ public final class PropertiesResolver {
return r; return r;
} }
private static String key(TypeSource typeSource) { private static String key(@Nullable TypeSource typeSource) {
if (typeSource == null) { if (typeSource == null) {
return ""; return "";
} }
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.resolver;
import com.intellij.psi.PsiEllipsisType; import com.intellij.psi.PsiEllipsisType;
import com.intellij.psi.PsiType; import com.intellij.psi.PsiType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptorImpl; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptorImpl;
@@ -58,7 +59,7 @@ public final class ValueParameterResolver {
PsiType psiType = parameter.getPsiParameter().getType(); PsiType psiType = parameter.getPsiParameter().getType();
// TODO: must be very slow, make it lazy? // TODO: must be very slow, make it lazy?
Name name = Name.identifier(parameter.getPsiParameter().getName() != null ? parameter.getPsiParameter().getName() : "p" + i); Name name = Name.identifier(getParameterName(i, parameter));
if (parameter.getJetValueParameter().name().length() > 0) { if (parameter.getJetValueParameter().name().length() > 0) {
name = Name.identifier(parameter.getJetValueParameter().name()); name = Name.identifier(parameter.getJetValueParameter().name());
@@ -114,6 +115,12 @@ public final class ValueParameterResolver {
} }
} }
@NotNull
private static String getParameterName(int number, @NotNull PsiParameterWrapper parameter) {
String psiParameterName = parameter.getPsiParameter().getName();
return psiParameterName != null ? psiParameterName : "p" + number;
}
public JavaDescriptorResolver.ValueParameterDescriptors resolveParameterDescriptors( public JavaDescriptorResolver.ValueParameterDescriptors resolveParameterDescriptors(
DeclarationDescriptor containingDeclaration, DeclarationDescriptor containingDeclaration,
List<PsiParameterWrapper> parameters, TypeVariableResolver typeVariableResolver List<PsiParameterWrapper> parameters, TypeVariableResolver typeVariableResolver
@@ -156,8 +163,8 @@ public final class ValueParameterResolver {
private JvmMethodParameterMeaning( private JvmMethodParameterMeaning(
JvmMethodParameterKind kind, JvmMethodParameterKind kind,
JetType receiverType, @Nullable JetType receiverType,
ValueParameterDescriptor valueParameterDescriptor @Nullable ValueParameterDescriptor valueParameterDescriptor
) { ) {
this.kind = kind; this.kind = kind;
this.receiverType = receiverType; this.receiverType = receiverType;