void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiMethod method = (PsiMethod)startElement.getParent(); final PsiCodeBlock methodBody = method.getBody(); final PsiStatement statement = ControlFlowUtils.getOnlyStatementInBlock(methodBody); if (!(statement instanceof PsiSynchronizedStatement synchronizedStatement)) { return; } final PsiCodeBlock body = synchronizedStatement.getBody(); if (body == null) { return; } final CommentTracker tracker = new CommentTracker(); tracker.markUnchanged(body); tracker.grabComments(methodBody); final PsiCodeBlock newBlock = (PsiCodeBlock)methodBody.replace(body); PsiElement first = newBlock.getFirstBodyElement(); if (first instanceof PsiWhiteSpace) first = first.getNextSibling(); if (first != null) { tracker.insertCommentsBefore(first); } final PsiModifierList modifierList = method.getModifierList(); modifierList.setModifierProperty(PsiModifier.SYNCHRONIZED, true); }