void (@NotNull PsiElement oldParameter, @NotNull PsiElement movedParameter, @NotNull PsiParameterList parameterList, boolean beforeParameter) { final PsiElement neighbour = beforeParameter ? PsiTreeUtil.skipWhitespacesAndCommentsBackward(oldParameter) : PsiTreeUtil.skipWhitespacesAndCommentsForward(oldParameter); if (neighbour == null) return; if (beforeParameter) { if (!PsiUtil.isJavaToken(neighbour, JavaTokenType.COMMA)) return; } else { if (!PsiUtil.isJavaToken(neighbour, JavaTokenType.RPARENTH) && !PsiUtil.isJavaToken(neighbour, JavaTokenType.COMMA)) return; } final String comments = beforeParameter ? CommentTracker.commentsBetween(neighbour, oldParameter) : CommentTracker.commentsBetween(oldParameter, neighbour); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(oldParameter.getProject()); final PsiCodeBlock block = factory.createCodeBlockFromText("{" + comments + "}", parameterList); for (PsiElement child : beforeParameter ? block.getChildren() : ArrayUtil.reverseArray(block.getChildren())) { if (child instanceof PsiComment || child instanceof PsiWhiteSpace) { if (beforeParameter) { parameterList.addBefore(child, movedParameter); } else { parameterList.addAfter(child, movedParameter); } } } }