weaken access as suggested by IDEA

This commit is contained in:
Alex Tkachman
2012-08-23 14:38:11 +03:00
parent 80d6de381f
commit 0fad8a66f4
4 changed files with 22 additions and 16 deletions
@@ -103,7 +103,7 @@ public final class TipsManager {
else { else {
Collection<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(); Collection<DeclarationDescriptor> descriptorsSet = Sets.newHashSet();
ArrayList<ReceiverDescriptor> result = new ArrayList<ReceiverDescriptor>(); List<ReceiverDescriptor> result = new ArrayList<ReceiverDescriptor>();
resolutionScope.getImplicitReceiversHierarchy(result); resolutionScope.getImplicitReceiversHierarchy(result);
for (ReceiverDescriptor receiverDescriptor : result) { for (ReceiverDescriptor receiverDescriptor : result) {
@@ -119,7 +119,10 @@ public final class TipsManager {
} }
@NotNull @NotNull
public static Collection<DeclarationDescriptor> getPackageReferenceVariants(JetSimpleNameExpression expression, BindingContext context) { public static Collection<DeclarationDescriptor> getPackageReferenceVariants(
JetSimpleNameExpression expression,
BindingContext context
) {
JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, expression); JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
if (resolutionScope != null) { if (resolutionScope != null) {
return excludeNonPackageDescriptors(resolutionScope.getAllDescriptors()); return excludeNonPackageDescriptors(resolutionScope.getAllDescriptors());
@@ -129,7 +132,8 @@ public final class TipsManager {
} }
public static Collection<DeclarationDescriptor> excludePrivateDescriptors( public static Collection<DeclarationDescriptor> excludePrivateDescriptors(
@NotNull Collection<DeclarationDescriptor> descriptors) { @NotNull Collection<DeclarationDescriptor> descriptors
) {
return Collections2.filter(descriptors, new Predicate<DeclarationDescriptor>() { return Collections2.filter(descriptors, new Predicate<DeclarationDescriptor>() {
@Override @Override
@@ -148,7 +152,7 @@ public final class TipsManager {
) { ) {
final Set<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(descriptors); final Set<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(descriptors);
final ArrayList<ReceiverDescriptor> result = new ArrayList<ReceiverDescriptor>(); final List<ReceiverDescriptor> result = new ArrayList<ReceiverDescriptor>();
scope.getImplicitReceiversHierarchy(result); scope.getImplicitReceiversHierarchy(result);
descriptorsSet.removeAll( descriptorsSet.removeAll(
@@ -169,9 +173,10 @@ public final class TipsManager {
return Lists.newArrayList(descriptorsSet); return Lists.newArrayList(descriptorsSet);
} }
private static Collection<DeclarationDescriptor> excludeNonPackageDescriptors( private static Collection<DeclarationDescriptor> excludeNonPackageDescriptors(
@NotNull Collection<DeclarationDescriptor> descriptors) { @NotNull Collection<DeclarationDescriptor> descriptors
) {
return Collections2.filter(descriptors, new Predicate<DeclarationDescriptor>() { return Collections2.filter(descriptors, new Predicate<DeclarationDescriptor>() {
@Override @Override
public boolean apply(DeclarationDescriptor declarationDescriptor) { public boolean apply(DeclarationDescriptor declarationDescriptor) {
@@ -195,12 +200,12 @@ public final class TipsManager {
descriptorsSet.addAll( descriptorsSet.addAll(
Collections2.filter(JetScopeUtils.getAllExtensions(externalScope), Collections2.filter(JetScopeUtils.getAllExtensions(externalScope),
new Predicate<CallableDescriptor>() { new Predicate<CallableDescriptor>() {
@Override @Override
public boolean apply(CallableDescriptor callableDescriptor) { public boolean apply(CallableDescriptor callableDescriptor) {
return ExpressionTypingUtils.checkIsExtensionCallable(receiverDescriptor, callableDescriptor); return ExpressionTypingUtils.checkIsExtensionCallable(receiverDescriptor, callableDescriptor);
} }
})); }));
return descriptorsSet; return descriptorsSet;
} }
@@ -173,7 +173,7 @@ public class ClosureAnnotator {
jetFile.accept(visitor); jetFile.accept(visitor);
} }
ArrayList<JetFile> namespaceFiles = new ArrayList<JetFile>(); Collection<JetFile> namespaceFiles = new ArrayList<JetFile>();
for (JetFile jetFile : entry.getValue()) { for (JetFile jetFile : entry.getValue()) {
Collection<JetDeclaration> fileFunctions = new ArrayList<JetDeclaration>(); Collection<JetDeclaration> fileFunctions = new ArrayList<JetDeclaration>();
for (JetDeclaration declaration : jetFile.getDeclarations()) { for (JetDeclaration declaration : jetFile.getDeclarations()) {
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import static org.jetbrains.jet.codegen.JetTypeMapper.TYPE_OBJECT; import static org.jetbrains.jet.codegen.JetTypeMapper.TYPE_OBJECT;
@@ -223,7 +224,7 @@ public abstract class CodegenContext {
public abstract boolean isStatic(); public abstract boolean isStatic();
public void copyAccessors(HashMap<DeclarationDescriptor, DeclarationDescriptor> accessors) { public void copyAccessors(Map<DeclarationDescriptor, DeclarationDescriptor> accessors) {
if (accessors != null) { if (accessors != null) {
if (this.accessors == null) { if (this.accessors == null) {
this.accessors = new HashMap<DeclarationDescriptor, DeclarationDescriptor>(); this.accessors = new HashMap<DeclarationDescriptor, DeclarationDescriptor>();
@@ -607,7 +607,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ObjectOrClosureCodegen closure = context.closure; ObjectOrClosureCodegen closure = context.closure;
int firstSuperArgument = -1; int firstSuperArgument = -1;
final LinkedList<JvmMethodParameterSignature> consArgTypes = final List<JvmMethodParameterSignature> consArgTypes =
new LinkedList<JvmMethodParameterSignature>(constructorMethod.getKotlinParameterTypes()); new LinkedList<JvmMethodParameterSignature>(constructorMethod.getKotlinParameterTypes());
int insert = 0; int insert = 0;
@@ -737,7 +737,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type classType = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL); Type classType = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL);
JvmClassName classname = JvmClassName.byType(classType); JvmClassName classname = JvmClassName.byType(classType);
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>(); Collection<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
for (JetDeclaration declaration : myClass.getDeclarations()) { for (JetDeclaration declaration : myClass.getDeclarations()) {
if (declaration instanceof JetNamedFunction) { if (declaration instanceof JetNamedFunction) {
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration); SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration);