Name validator for introduce variable action.

This commit is contained in:
Alefas
2012-02-15 15:51:11 +04:00
parent 2ec05429b8
commit 94402c5f3f
3 changed files with 132 additions and 47 deletions
@@ -68,32 +68,34 @@ public final class TipsManager {
excludePrivateDescriptors(expressionType.getMemberScope().getAllDescriptors()),
resolutionScope, new ExpressionReceiver(receiverExpression, expressionType));
}
return Collections.emptyList();
} else {
JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
if (resolutionScope != null) {
if (expression.getParent() instanceof JetImportDirective || expression.getParent() instanceof JetNamespaceHeader) {
return excludeNonPackageDescriptors(resolutionScope.getAllDescriptors());
} else {
HashSet<DeclarationDescriptor> descriptorsSet = Sets.newHashSet();
ArrayList<ReceiverDescriptor> result = new ArrayList<ReceiverDescriptor>();
resolutionScope.getImplicitReceiversHierarchy(result);
for (ReceiverDescriptor receiverDescriptor : result) {
JetType receiverType = receiverDescriptor.getType();
descriptorsSet.addAll(receiverType.getMemberScope().getAllDescriptors());
}
descriptorsSet.addAll(resolutionScope.getAllDescriptors());
return excludeNotCallableExtensions(excludePrivateDescriptors(descriptorsSet), resolutionScope);
}
}
return getVariantsNoReceiver(expression, context);
}
return Collections.emptyList();
}
public static Collection<DeclarationDescriptor> getVariantsNoReceiver(JetExpression expression, BindingContext context) {
JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
if (resolutionScope != null) {
if (expression.getParent() instanceof JetImportDirective || expression.getParent() instanceof JetNamespaceHeader) {
return excludeNonPackageDescriptors(resolutionScope.getAllDescriptors());
} else {
HashSet<DeclarationDescriptor> descriptorsSet = Sets.newHashSet();
ArrayList<ReceiverDescriptor> result = new ArrayList<ReceiverDescriptor>();
resolutionScope.getImplicitReceiversHierarchy(result);
for (ReceiverDescriptor receiverDescriptor : result) {
JetType receiverType = receiverDescriptor.getType();
descriptorsSet.addAll(receiverType.getMemberScope().getAllDescriptors());
}
descriptorsSet.addAll(resolutionScope.getAllDescriptors());
return excludeNotCallableExtensions(excludePrivateDescriptors(descriptorsSet), resolutionScope);
}
}
return Collections.emptyList();
}
public static Collection<DeclarationDescriptor> excludePrivateDescriptors(
@NotNull Collection<DeclarationDescriptor> descriptors) {