mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Treat method as simple if its code block doesn't contain any linefeeds (IDEA-136990)
This commit is contained in:
@@ -368,18 +368,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
|
||||
private boolean shouldHandleAsSimpleMethod(@NotNull PsiMethod method) {
|
||||
if (!mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE) return false;
|
||||
|
||||
boolean skipElement = true;
|
||||
for (PsiElement element : method.getChildren()) {
|
||||
if (element instanceof PsiTypeElement) skipElement = false;
|
||||
if (skipElement) continue;
|
||||
|
||||
if (element.textContains('\n')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
PsiCodeBlock body = method.getBody();
|
||||
return body != null && !body.textContains('\n');
|
||||
}
|
||||
|
||||
private static int getMethodHeaderStartOffset(@NotNull PsiMethod method) {
|
||||
|
||||
@@ -329,4 +329,19 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest {
|
||||
"}\n"
|
||||
);
|
||||
}
|
||||
|
||||
public void testMethodIsSimple_IfCodeBlockHasNoLinefeeds() {
|
||||
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
|
||||
doClassTest(
|
||||
"public ModelAndView handleRequestInternalEmptyMulti(\n" +
|
||||
" final HttpServletRequest httpServletRequest,\n" +
|
||||
" final HttpServletResponse response)\n" +
|
||||
" throws IOException {}",
|
||||
"public ModelAndView handleRequestInternalEmptyMulti(\n" +
|
||||
" final HttpServletRequest httpServletRequest,\n" +
|
||||
" final HttpServletResponse response)\n" +
|
||||
" throws IOException {}"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user