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) {
"}\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 {}"
+ );
+ }
+
}