Refactor: eliminate most of ResolverScopeData#getClassOrNamespaceDescriptor() usages
This commit is contained in:
+7
-8
@@ -81,7 +81,7 @@ public final class JavaFunctionResolver {
|
||||
@Nullable
|
||||
private SimpleFunctionDescriptor resolveMethodToFunctionDescriptor(
|
||||
@NotNull final PsiClass psiClass, final PsiMethodWrapper method,
|
||||
@NotNull ResolverScopeData scopeData
|
||||
@NotNull ResolverScopeData scopeData, @NotNull ClassOrNamespaceDescriptor ownerDescriptor
|
||||
) {
|
||||
PsiType returnPsiType = method.getReturnType();
|
||||
if (returnPsiType == null) {
|
||||
@@ -109,7 +109,7 @@ public final class JavaFunctionResolver {
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
|
||||
scopeData.getClassOrNamespaceDescriptor(),
|
||||
ownerDescriptor,
|
||||
annotationResolver.resolveAnnotations(psiMethod),
|
||||
Name.identifier(method.getName()),
|
||||
DescriptorKindUtils.flagsToKind(method.getJetMethodAnnotation().kind())
|
||||
@@ -145,7 +145,7 @@ public final class JavaFunctionResolver {
|
||||
|
||||
functionDescriptorImpl.initialize(
|
||||
valueParameterDescriptors.getReceiverType(),
|
||||
DescriptorUtils.getExpectedThisObjectIfNeeded(scopeData.getClassOrNamespaceDescriptor()),
|
||||
DescriptorUtils.getExpectedThisObjectIfNeeded(ownerDescriptor),
|
||||
methodTypeParameters,
|
||||
valueParameterDescriptors.getDescriptors(),
|
||||
returnType,
|
||||
@@ -177,7 +177,7 @@ public final class JavaFunctionResolver {
|
||||
|
||||
Set<SimpleFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
||||
for (PsiMethodWrapper method : namedMembers.getMethods()) {
|
||||
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData);
|
||||
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData, owner);
|
||||
if (function != null) {
|
||||
functionsFromCurrent.add(function);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public final class JavaFunctionResolver {
|
||||
if (owner instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
|
||||
|
||||
Set<SimpleFunctionDescriptor> functionsFromSupertypes = getFunctionsFromSupertypes(scopeData, methodName);
|
||||
Set<SimpleFunctionDescriptor> functionsFromSupertypes = getFunctionsFromSupertypes(methodName, owner);
|
||||
|
||||
OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor,
|
||||
new OverrideResolver.DescriptorSink() {
|
||||
@@ -260,11 +260,10 @@ public final class JavaFunctionResolver {
|
||||
|
||||
@NotNull
|
||||
private static Set<SimpleFunctionDescriptor> getFunctionsFromSupertypes(
|
||||
ResolverScopeData scopeData,
|
||||
Name methodName
|
||||
@NotNull Name methodName, @NotNull ClassOrNamespaceDescriptor classOrNamespaceDescriptor
|
||||
) {
|
||||
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)) {
|
||||
r.add((SimpleFunctionDescriptor) function);
|
||||
}
|
||||
|
||||
+8
-6
@@ -101,7 +101,7 @@ public final class JavaPropertyResolver {
|
||||
|
||||
@NotNull
|
||||
private Set<VariableDescriptor> resolveNamedGroupProperties(
|
||||
@NotNull ClassOrNamespaceDescriptor owner,
|
||||
@NotNull ClassOrNamespaceDescriptor ownerDescriptor,
|
||||
@NotNull ResolverScopeData scopeData,
|
||||
@NotNull NamedMembers namedMembers,
|
||||
@NotNull Name propertyName,
|
||||
@@ -122,13 +122,13 @@ public final class JavaPropertyResolver {
|
||||
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();
|
||||
|
||||
generateOverrides(owner, propertyName, propertiesFromCurrent, propertiesFromSupertypes, properties);
|
||||
generateOverrides(ownerDescriptor, propertyName, propertiesFromCurrent, propertiesFromSupertypes, properties);
|
||||
OverrideResolver.resolveUnknownVisibilities(properties, trace);
|
||||
|
||||
properties.addAll(propertiesFromCurrent);
|
||||
@@ -430,9 +430,11 @@ public final class JavaPropertyResolver {
|
||||
}
|
||||
|
||||
@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>();
|
||||
for (JetType supertype : DescriptorResolverUtils.getSupertypes(scopeData.getClassOrNamespaceDescriptor())) {
|
||||
for (JetType supertype : DescriptorResolverUtils.getSupertypes(ownerDescriptor)) {
|
||||
for (VariableDescriptor property : supertype.getMemberScope().getProperties(propertyName)) {
|
||||
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
|
||||
if (getContainingDeclaration() instanceof JavaNamespaceDescriptor) {
|
||||
result.addAll(semanticServices.getDescriptorResolver().resolveInnerClasses(
|
||||
|
||||
Reference in New Issue
Block a user