Smarter members sorting.

This commit is contained in:
Evgeny Gerashchenko
2012-12-26 17:52:40 +04:00
parent b13a99d4cd
commit 0df966323d
2 changed files with 22 additions and 14 deletions
@@ -32,21 +32,28 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
}
private static int getDeclarationPriority(DeclarationDescriptor descriptor) {
if (descriptor instanceof ClassDescriptor) {
return 4;
if (descriptor instanceof ConstructorDescriptor) {
return 6;
}
else if (descriptor instanceof PropertyDescriptor) {
return 3;
}
else if (descriptor instanceof FunctionDescriptor) {
FunctionDescriptor fun = (FunctionDescriptor)descriptor;
if (fun.getReceiverParameter() == null) {
return 2;
if (((PropertyDescriptor)descriptor).getReceiverParameter() == null) {
return 5;
}
else {
return 1;
return 4;
}
}
else if (descriptor instanceof FunctionDescriptor) {
if (((FunctionDescriptor)descriptor).getReceiverParameter() == null) {
return 3;
}
else {
return 2;
}
}
else if (descriptor instanceof ClassDescriptor) {
return 1;
}
return 0;
}
@@ -71,7 +78,8 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
ReceiverParameterDescriptor c1ReceiverParameter = c1.getReceiverParameter();
ReceiverParameterDescriptor c2ReceiverParameter = c2.getReceiverParameter();
if (c1ReceiverParameter != null && c2ReceiverParameter != null) {
assert (c1ReceiverParameter != null) == (c2ReceiverParameter != null);
if (c1ReceiverParameter != null) {
String r1 = DescriptorRenderer.TEXT.renderType(c1ReceiverParameter.getType());
String r2 = DescriptorRenderer.TEXT.renderType(c2ReceiverParameter.getType());
int receiversCompareTo = r1.compareTo(r2);