mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
extract method: disable in sub-selection of annotation
e.g. in package-info.java there is no default class to choose as target GitOrigin-RevId: 578998ac49f4da01a7365523938e5983d1a639f4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
69801c215d
commit
fa4d7ba5a7
@@ -235,9 +235,6 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (PsiTreeUtil.getParentOfType(myElements[0], PsiAnnotation.class) != null) {
|
||||
throw new PrepareFailedException("Unable to extract method from annotation value", myElements[0]);
|
||||
}
|
||||
final PsiElement codeFragment = ControlFlowUtil.findCodeFragment(myElements[0]);
|
||||
myCodeFragmentMember = codeFragment.getUserData(ElementToWorkOn.PARENT);
|
||||
if (myCodeFragmentMember == null) {
|
||||
@@ -249,6 +246,10 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
myCodeFragmentMember = ControlFlowUtil.findCodeFragment(context).getParent();
|
||||
}
|
||||
|
||||
if (PsiTreeUtil.getParentOfType(myElements[0].isPhysical() ? myElements[0] : myCodeFragmentMember, PsiAnnotation.class) != null) {
|
||||
throw new PrepareFailedException("Unable to extract method from annotation value", myElements[0]);
|
||||
}
|
||||
|
||||
myControlFlowWrapper = new ControlFlowWrapper(myProject, codeFragment, myElements);
|
||||
|
||||
try {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
@SuppressWarnings("b<selection>a</selection>r")
|
||||
@@ -1421,6 +1421,15 @@ public class ExtractMethodTest extends LightJavaCodeInsightTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testExtractFromAnnotation1() throws Exception {
|
||||
try {
|
||||
doTest();
|
||||
fail("Should not work for annotations");
|
||||
}
|
||||
catch (PrepareFailedException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
private void doTestDisabledParam() throws PrepareFailedException {
|
||||
final CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
settings.ELSE_ON_NEW_LINE = true;
|
||||
|
||||
Reference in New Issue
Block a user