[java-completion] SemicolonFixer: cosmetic

GitOrigin-RevId: 4cf39ca29f402fad784fde227676a4139b849c41
This commit is contained in:
Tagir Valeev
2025-03-07 13:38:36 +00:00
committed by intellij-monorepo-bot
parent 65b99c3554
commit af80b1afd1
@@ -13,15 +13,12 @@ import org.jetbrains.annotations.Nullable;
public class SemicolonFixer extends AbstractBasicSemicolonFixer {
@Override
protected boolean fixReturn(@NotNull Editor editor, @Nullable PsiElement psiElement) {
if (psiElement instanceof PsiReturnStatement) {
if (psiElement instanceof PsiReturnStatement stmt) {
PsiMethod method = PsiTreeUtil.getParentOfType(psiElement, PsiMethod.class, true, PsiLambdaExpression.class);
if (method != null && PsiTypes.voidType().equals(method.getReturnType())) {
PsiReturnStatement stmt = (PsiReturnStatement)psiElement;
if (stmt.getReturnValue() != null) {
Document doc = editor.getDocument();
doc.insertString(stmt.getTextRange().getStartOffset() + "return".length(), ";");
return true;
}
if (method != null && PsiTypes.voidType().equals(method.getReturnType()) && stmt.getReturnValue() != null) {
Document doc = editor.getDocument();
doc.insertString(stmt.getTextRange().getStartOffset() + "return".length(), ";");
return true;
}
}
return false;