Smarter members sorting.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user