mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Java: Prevent extracting method from empty parentheses (IDEA-182482)
This commit is contained in:
@@ -200,6 +200,7 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
* Invoked in atomic action
|
||||
*/
|
||||
public boolean prepare(@Nullable Pass<ExtractMethodProcessor> pass) throws PrepareFailedException {
|
||||
if (myElements.length == 0) return false;
|
||||
myExpression = null;
|
||||
if (myElements.length == 1 && myElements[0] instanceof PsiExpression) {
|
||||
final PsiExpression expression = (PsiExpression)myElements[0];
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class ExtractEmptyBlock {
|
||||
void foo() {
|
||||
<selection>{}</selection>
|
||||
}
|
||||
}
|
||||
@@ -1217,6 +1217,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testEmptyBlockStatement() throws Exception {
|
||||
doExitPointsTest(false);
|
||||
}
|
||||
|
||||
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