Refactor: eliminate most of ResolverScopeData#getClassOrNamespaceDescriptor() usages
This commit is contained in:
+7
-8
@@ -81,7 +81,7 @@ public final class JavaFunctionResolver {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private SimpleFunctionDescriptor resolveMethodToFunctionDescriptor(
|
private SimpleFunctionDescriptor resolveMethodToFunctionDescriptor(
|
||||||
@NotNull final PsiClass psiClass, final PsiMethodWrapper method,
|
@NotNull final PsiClass psiClass, final PsiMethodWrapper method,
|
||||||
@NotNull ResolverScopeData scopeData
|
@NotNull ResolverScopeData scopeData, @NotNull ClassOrNamespaceDescriptor ownerDescriptor
|
||||||
) {
|
) {
|
||||||
PsiType returnPsiType = method.getReturnType();
|
PsiType returnPsiType = method.getReturnType();
|
||||||
if (returnPsiType == null) {
|
if (returnPsiType == null) {
|
||||||
@@ -109,7 +109,7 @@ public final class JavaFunctionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
|
||||||
scopeData.getClassOrNamespaceDescriptor(),
|
ownerDescriptor,
|
||||||
annotationResolver.resolveAnnotations(psiMethod),
|
annotationResolver.resolveAnnotations(psiMethod),
|
||||||
Name.identifier(method.getName()),
|
Name.identifier(method.getName()),
|
||||||
DescriptorKindUtils.flagsToKind(method.getJetMethodAnnotation().kind())
|
DescriptorKindUtils.flagsToKind(method.getJetMethodAnnotation().kind())
|
||||||
@@ -145,7 +145,7 @@ public final class JavaFunctionResolver {
|
|||||||
|
|
||||||
functionDescriptorImpl.initialize(
|
functionDescriptorImpl.initialize(
|
||||||
valueParameterDescriptors.getReceiverType(),
|
valueParameterDescriptors.getReceiverType(),
|
||||||
DescriptorUtils.getExpectedThisObjectIfNeeded(scopeData.getClassOrNamespaceDescriptor()),
|
DescriptorUtils.getExpectedThisObjectIfNeeded(ownerDescriptor),
|
||||||
methodTypeParameters,
|
methodTypeParameters,
|
||||||
valueParameterDescriptors.getDescriptors(),
|
valueParameterDescriptors.getDescriptors(),
|
||||||
returnType,
|
returnType,
|
||||||
@@ -177,7 +177,7 @@ public final class JavaFunctionResolver {
|
|||||||
|
|
||||||
Set<SimpleFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
Set<SimpleFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
||||||
for (PsiMethodWrapper method : namedMembers.getMethods()) {
|
for (PsiMethodWrapper method : namedMembers.getMethods()) {
|
||||||
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData);
|
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData, owner);
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
functionsFromCurrent.add(function);
|
functionsFromCurrent.add(function);
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ public final class JavaFunctionResolver {
|
|||||||
if (owner instanceof ClassDescriptor) {
|
if (owner instanceof ClassDescriptor) {
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
|
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
|
||||||
|
|
||||||
Set<SimpleFunctionDescriptor> functionsFromSupertypes = getFunctionsFromSupertypes(scopeData, methodName);
|
Set<SimpleFunctionDescriptor> functionsFromSupertypes = getFunctionsFromSupertypes(methodName, owner);
|
||||||
|
|
||||||
OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor,
|
OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor,
|
||||||
new OverrideResolver.DescriptorSink() {
|
new OverrideResolver.DescriptorSink() {
|
||||||
@@ -260,11 +260,10 @@ public final class JavaFunctionResolver {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<SimpleFunctionDescriptor> getFunctionsFromSupertypes(
|
private static Set<SimpleFunctionDescriptor> getFunctionsFromSupertypes(
|
||||||
ResolverScopeData scopeData,
|
@NotNull Name methodName, @NotNull ClassOrNamespaceDescriptor classOrNamespaceDescriptor
|
||||||
Name methodName
|
|
||||||
) {
|
) {
|
||||||
Set<SimpleFunctionDescriptor> r = Sets.newLinkedHashSet();
|
Set<SimpleFunctionDescriptor> r = Sets.newLinkedHashSet();
|
||||||
for (JetType supertype : DescriptorResolverUtils.getSupertypes(scopeData.getClassOrNamespaceDescriptor())) {
|
for (JetType supertype : DescriptorResolverUtils.getSupertypes(classOrNamespaceDescriptor)) {
|
||||||
for (FunctionDescriptor function : supertype.getMemberScope().getFunctions(methodName)) {
|
for (FunctionDescriptor function : supertype.getMemberScope().getFunctions(methodName)) {
|
||||||
r.add((SimpleFunctionDescriptor) function);
|
r.add((SimpleFunctionDescriptor) function);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-6
@@ -101,7 +101,7 @@ public final class JavaPropertyResolver {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Set<VariableDescriptor> resolveNamedGroupProperties(
|
private Set<VariableDescriptor> resolveNamedGroupProperties(
|
||||||
@NotNull ClassOrNamespaceDescriptor owner,
|
@NotNull ClassOrNamespaceDescriptor ownerDescriptor,
|
||||||
@NotNull ResolverScopeData scopeData,
|
@NotNull ResolverScopeData scopeData,
|
||||||
@NotNull NamedMembers namedMembers,
|
@NotNull NamedMembers namedMembers,
|
||||||
@NotNull Name propertyName,
|
@NotNull Name propertyName,
|
||||||
@@ -122,13 +122,13 @@ public final class JavaPropertyResolver {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
propertiesFromCurrent.add(resolveProperty(owner, scopeData, propertyName, context, propertyPsiData));
|
propertiesFromCurrent.add(resolveProperty(ownerDescriptor, scopeData, propertyName, context, propertyPsiData));
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<PropertyDescriptor> propertiesFromSupertypes = getPropertiesFromSupertypes(scopeData, propertyName);
|
Set<PropertyDescriptor> propertiesFromSupertypes = getPropertiesFromSupertypes(propertyName, ownerDescriptor);
|
||||||
Set<PropertyDescriptor> properties = Sets.newHashSet();
|
Set<PropertyDescriptor> properties = Sets.newHashSet();
|
||||||
|
|
||||||
generateOverrides(owner, propertyName, propertiesFromCurrent, propertiesFromSupertypes, properties);
|
generateOverrides(ownerDescriptor, propertyName, propertiesFromCurrent, propertiesFromSupertypes, properties);
|
||||||
OverrideResolver.resolveUnknownVisibilities(properties, trace);
|
OverrideResolver.resolveUnknownVisibilities(properties, trace);
|
||||||
|
|
||||||
properties.addAll(propertiesFromCurrent);
|
properties.addAll(propertiesFromCurrent);
|
||||||
@@ -430,9 +430,11 @@ public final class JavaPropertyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<PropertyDescriptor> getPropertiesFromSupertypes(ResolverScopeData scopeData, Name propertyName) {
|
private static Set<PropertyDescriptor> getPropertiesFromSupertypes(
|
||||||
|
@NotNull Name propertyName, @NotNull ClassOrNamespaceDescriptor ownerDescriptor
|
||||||
|
) {
|
||||||
Set<PropertyDescriptor> r = new HashSet<PropertyDescriptor>();
|
Set<PropertyDescriptor> r = new HashSet<PropertyDescriptor>();
|
||||||
for (JetType supertype : DescriptorResolverUtils.getSupertypes(scopeData.getClassOrNamespaceDescriptor())) {
|
for (JetType supertype : DescriptorResolverUtils.getSupertypes(ownerDescriptor)) {
|
||||||
for (VariableDescriptor property : supertype.getMemberScope().getProperties(propertyName)) {
|
for (VariableDescriptor property : supertype.getMemberScope().getProperties(propertyName)) {
|
||||||
r.add((PropertyDescriptor) property);
|
r.add((PropertyDescriptor) property);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -153,7 +153,10 @@ public abstract class JavaBaseScope extends JetScopeImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeInnerClasses(@NotNull PsiClass psiClass, @NotNull Collection<DeclarationDescriptor> result) {
|
private void computeInnerClasses(
|
||||||
|
@NotNull PsiClass psiClass,
|
||||||
|
@NotNull Collection<DeclarationDescriptor> result
|
||||||
|
) {
|
||||||
// TODO: Trying to hack the situation when we produce namespace descriptor for java class and still want to see inner classes
|
// TODO: Trying to hack the situation when we produce namespace descriptor for java class and still want to see inner classes
|
||||||
if (getContainingDeclaration() instanceof JavaNamespaceDescriptor) {
|
if (getContainingDeclaration() instanceof JavaNamespaceDescriptor) {
|
||||||
result.addAll(semanticServices.getDescriptorResolver().resolveInnerClasses(
|
result.addAll(semanticServices.getDescriptorResolver().resolveInnerClasses(
|
||||||
|
|||||||
Reference in New Issue
Block a user