mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
corrected method header text range calculation to work correctly with constructors (fixes IDEA-132781)
This commit is contained in:
@@ -381,11 +381,13 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static int getMethodHeaderStartOffset(@NotNull PsiMethod method) {
|
||||
for (PsiElement element : method.getChildren()) {
|
||||
if (element instanceof PsiTypeElement) {
|
||||
return element.getTextRange().getStartOffset();
|
||||
PsiTypeParameterList typeParameterList = PsiTreeUtil.findChildOfType(method, PsiTypeParameterList.class);
|
||||
if (typeParameterList != null) {
|
||||
PsiElement nextNonWsElem = PsiTreeUtil.skipSiblingsForward(typeParameterList, PsiWhiteSpace.class);
|
||||
if (nextNonWsElem != null) {
|
||||
return nextNonWsElem.getTextRange().getStartOffset();
|
||||
}
|
||||
}
|
||||
return method.getTextRange().getStartOffset();
|
||||
|
||||
@@ -289,4 +289,32 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest {
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
public void testConstructorLeftBraceWithComment() {
|
||||
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
|
||||
doClassTest(
|
||||
"/**\n" +
|
||||
" *\n" +
|
||||
" */\n" +
|
||||
" public Test() {\n" +
|
||||
"}\n",
|
||||
"/**\n" +
|
||||
" *\n" +
|
||||
" */\n" +
|
||||
"public Test() {\n" +
|
||||
"}\n"
|
||||
);
|
||||
}
|
||||
|
||||
public void testConstructorLeftBraceWithAnnotation() {
|
||||
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
|
||||
doClassTest(
|
||||
" @Deprecated\n" +
|
||||
"public Test() {\n" +
|
||||
"}\n",
|
||||
"@Deprecated\n" +
|
||||
"public Test() {\n" +
|
||||
"}\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user