mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Extract Method] generate method with newline between braces, since otherwise with enabled "Keep simple methods in one line" formatter will keep extracted method in one line
This commit is contained in:
@@ -251,7 +251,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
}
|
||||
|
||||
final String canonicalText = returnType.getCanonicalText(true);
|
||||
final PsiJavaFile aFile = createDummyJavaFile("class _Dummy_ { public " + canonicalText + " " + name + "() {} }");
|
||||
final PsiJavaFile aFile = createDummyJavaFile("class _Dummy_ { public " + canonicalText + " " + name + "() {\n} }");
|
||||
final PsiClass[] classes = aFile.getClasses();
|
||||
if (classes.length < 1) {
|
||||
throw new IncorrectOperationException("Class was not created. Method name: " + name + "; return type: " + canonicalText);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
public class NewTestXl {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int b = <selection>100 + 1222</selection>;
|
||||
System.out.println("ASfsdf");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class NewTestXl {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int b = newMethod();
|
||||
System.out.println("ASfsdf");
|
||||
}
|
||||
|
||||
private static int newMethod() {
|
||||
return 100 + 1222;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -762,6 +762,13 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
public void testTargetAnonymous() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimpleMethodsInOneLine() throws Exception {
|
||||
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
CommonCodeStyleSettings javaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
javaSettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExtractUnresolvedLambdaParameter() throws Exception {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user