IDEA-259050 refactor this: don't suggest Move Instance Method under constructor declaration

GitOrigin-RevId: f3fd88cdbc1ec8eb6cfd916673b4b22aea7e6f46
This commit is contained in:
Alexandr Suhinin
2021-01-07 16:08:03 +00:00
committed by intellij-monorepo-bot
parent 6b0c0c462d
commit db251eff72
3 changed files with 8 additions and 0 deletions
@@ -36,6 +36,7 @@ public class MoveInstanceMethodHandlerDelegate extends MoveHandlerDelegate {
if (!(element instanceof PsiMethod)) return false;
if (element instanceof SyntheticElement) return false;
PsiMethod method = (PsiMethod) element;
if (method.isConstructor()) return false;
if (method.hasModifierProperty(PsiModifier.STATIC)) return false;
return targetContainer == null || super.canMove(elements, targetContainer, reference);
}
@@ -0,0 +1,3 @@
public class Test {
Test<caret>() {}
}
@@ -103,6 +103,10 @@ class RefactorThisTest: LightJavaCodeInsightTestCase() {
assertTrue(doActionExists<MoveAction>())
}
fun testMoveOnClassDeclaration() {
assertTrue(doActionExists<MoveAction>())
}
private inline fun <reified A> doActionExists(): Boolean {
configureByFile("$BASE_PATH/${getTestName(false)}.java")
return findAvailableActions().any { action -> action is A }