Revert temporary commit "-- Attempt to fix completion for extensions"

This reverts commit b70f9cd675.
This commit is contained in:
Nikolay Krasko
2014-06-25 14:52:41 +04:00
parent c98ec96194
commit 3f2d65762b
3 changed files with 14 additions and 36 deletions
@@ -16,11 +16,8 @@
package org.jetbrains.jet.lang.types.expressions;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
@@ -46,7 +43,6 @@ import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeUtils;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
@@ -244,32 +240,6 @@ public class ExpressionTypingUtils {
return callableExtensionDescriptors;
}
public static Collection<CallableDescriptor> filterCallableExtensions(
@NotNull final ReceiverValue receiverArgument, @NotNull Collection<CallableDescriptor> extensions) {
final Map<JetType, Boolean> filterCache = new HashMap<JetType, Boolean>();
return Collections2.filter(extensions,
new Predicate<CallableDescriptor>() {
@Override
public boolean apply(CallableDescriptor callableDescriptor) {
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
if (receiverParameter == null) {
return false;
}
JetType type = receiverParameter.getType();
if (filterCache.containsKey(type)) {
return filterCache.get(type);
}
boolean isExtensionCallable = checkIsExtensionCallable(receiverArgument, callableDescriptor);
filterCache.put(type, isExtensionCallable);
return isExtensionCallable;
}
});
}
/*
* Checks if receiver declaration could be resolved to call expected receiver.
*/
@@ -324,7 +294,7 @@ public class ExpressionTypingUtils {
}
private static Set<Name> collectUsedTypeNames(@NotNull JetType jetType) {
Set<Name> typeNames = Sets.newHashSet();
Set<Name> typeNames = new HashSet<Name>();
ClassifierDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor();
if (descriptor != null) {
@@ -39,11 +39,11 @@ public class TypeCheckingProcedure {
// as the second parameter, applying the substitution of type arguments to it
@Nullable
public static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype, @NotNull TypingConstraints typingConstraints) {
TypeConstructor subtypeConstructor = subtype.getConstructor();
if (typingConstraints.assertEqualTypeConstructors(subtypeConstructor, supertype.getConstructor())) {
TypeConstructor constructor = subtype.getConstructor();
if (typingConstraints.assertEqualTypeConstructors(constructor, supertype.getConstructor())) {
return subtype;
}
for (JetType immediateSupertype : subtypeConstructor.getSupertypes()) {
for (JetType immediateSupertype : constructor.getSupertypes()) {
JetType correspondingSupertype = findCorrespondingSupertype(immediateSupertype, supertype, typingConstraints);
if (correspondingSupertype != null) {
return TypeSubstitutor.create(subtype).safeSubstitute(correspondingSupertype, Variance.INVARIANT);
@@ -194,7 +194,7 @@ public final class TipsManager {
private static Set<DeclarationDescriptor> includeExternalCallableExtensions(
@NotNull Collection<DeclarationDescriptor> descriptors,
@NotNull JetScope externalScope,
@NotNull ReceiverValue receiverValue
@NotNull final ReceiverValue receiverValue
) {
// It's impossible to add extension function for package
JetType receiverType = receiverValue.getType();
@@ -203,7 +203,15 @@ public final class TipsManager {
}
Set<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(descriptors);
descriptorsSet.addAll(ExpressionTypingUtils.filterCallableExtensions(receiverValue, JetScopeUtils.getAllExtensions(externalScope)));
descriptorsSet.addAll(
Collections2.filter(JetScopeUtils.getAllExtensions(externalScope),
new Predicate<CallableDescriptor>() {
@Override
public boolean apply(CallableDescriptor callableDescriptor) {
return ExpressionTypingUtils.checkIsExtensionCallable(receiverValue, callableDescriptor);
}
}));
return descriptorsSet;
}