boolean (PsiElement element) { if (!(element instanceof PsiComment comment) || element instanceof PsiDocComment || element.getTextOffset() == 0) { return false; } if (comment instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)comment)) { return false; } final IElementType type = comment.getTokenType(); if (JavaTokenType.C_STYLE_COMMENT.equals(type)) { if (!comment.getText().endsWith("*/")) { return false; } } else if (!JavaTokenType.END_OF_LINE_COMMENT.equals(type)) { return false; // can't move JSP comments } final PsiElement prevSibling = PsiTreeUtil.prevLeaf(element); if (prevSibling == null || prevSibling.getTextLength() == 0) { return false; } if (!(prevSibling instanceof PsiWhiteSpace)) { return true; } return prevSibling.getText().indexOf('\n') < 0 && PsiTreeUtil.prevLeaf(prevSibling) != null; }