MemberComparator: enum entries have top priority and are never reordered
Fix rendering accordingly
This commit is contained in:
@@ -42,6 +42,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumEntry;
|
||||
import static org.jetbrains.jet.test.util.DescriptorValidator.ValidationVisitor.errorTypesForbidden;
|
||||
|
||||
public class RecursiveDescriptorComparator {
|
||||
@@ -93,7 +94,8 @@ public class RecursiveDescriptorComparator {
|
||||
@NotNull Printer printer,
|
||||
boolean topLevel
|
||||
) {
|
||||
if ((descriptor instanceof ClassOrPackageFragmentDescriptor || descriptor instanceof PackageViewDescriptor) && !topLevel) {
|
||||
if (!isEnumEntry(descriptor) &&
|
||||
(descriptor instanceof ClassOrPackageFragmentDescriptor || descriptor instanceof PackageViewDescriptor) && !topLevel) {
|
||||
printer.println();
|
||||
}
|
||||
|
||||
@@ -154,6 +156,10 @@ public class RecursiveDescriptorComparator {
|
||||
else {
|
||||
printer.printlnWithNoIndent();
|
||||
}
|
||||
|
||||
if (isEnumEntry(descriptor)) {
|
||||
printer.println();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.jetbrains.jet.renderer.DescriptorRendererBuilder;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumEntry;
|
||||
|
||||
public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
public static final MemberComparator INSTANCE = new MemberComparator();
|
||||
|
||||
@@ -33,7 +35,10 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
}
|
||||
|
||||
private static int getDeclarationPriority(DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof ConstructorDescriptor) {
|
||||
if (isEnumEntry(descriptor)) {
|
||||
return 7;
|
||||
}
|
||||
else if (descriptor instanceof ConstructorDescriptor) {
|
||||
return 6;
|
||||
}
|
||||
else if (descriptor instanceof PropertyDescriptor) {
|
||||
@@ -64,6 +69,10 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
if (prioritiesCompareTo != 0) {
|
||||
return prioritiesCompareTo;
|
||||
}
|
||||
if (isEnumEntry(o1) && isEnumEntry(o2)) {
|
||||
//never reorder enum entries
|
||||
return 0;
|
||||
}
|
||||
|
||||
int namesCompareTo = o1.getName().compareTo(o2.getName());
|
||||
if (namesCompareTo != 0) {
|
||||
|
||||
Reference in New Issue
Block a user