restore comparable quick fixes and intention actions sorting

This commit is contained in:
Alexander Doroshko
2017-04-12 15:31:41 +03:00
parent 4bc5524ac0
commit 8bd4f4b523
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -143,7 +143,7 @@ public class IntentionActionWithTextCaching implements Comparable<IntentionActio
}
// IntentionAction which wraps the original action and then marks it as executed to hide it from the popup to avoid invoking it twice accidentally
private class MyIntentionAction implements IntentionAction,IntentionActionDelegate {
private class MyIntentionAction implements IntentionAction, IntentionActionDelegate, Comparable<MyIntentionAction> {
private final IntentionAction myAction;
private final BiConsumer<IntentionActionWithTextCaching, IntentionAction> myMarkInvoked;
@@ -204,5 +204,18 @@ public class IntentionActionWithTextCaching implements Comparable<IntentionActio
public PsiElement getElementToMakeWritable(@NotNull PsiFile currentFile) {
return myAction.getElementToMakeWritable(currentFile);
}
@Override
public int compareTo(@NotNull final MyIntentionAction other) {
if (myAction instanceof Comparable) {
//noinspection unchecked
return ((Comparable)myAction).compareTo(other.getDelegate());
}
if (other.getDelegate() instanceof Comparable) {
//noinspection unchecked
return ((Comparable)other.getDelegate()).compareTo(myAction);
}
return Comparing.compare(getText(), other.getText());
}
}
}