PsiElement (LeafPsiElement element) { YAMLKeyValue keyValue = findPrecedingKeyValueWithNoValue(element); assert keyValue != null : "Should come here only for YAMLKeyValue with no value and a following indent"; PsiComment nextComment = ObjectUtils.tryCast(skipNonNewlineSpaces(keyValue), PsiComment.class); if (nextComment != null) { keyValue.addBefore(myGenerator.createSpace(), null); keyValue.addBefore(nextComment.copy(), null); } keyValue.addBefore(myGenerator.createEol(), null); keyValue.addBefore(myGenerator.createIndent(element.getTextLength()), null); PsiElement prev = element.getPrevSibling(); if (prev != null) prev.delete(); element.delete(); if (nextComment != null) nextComment.delete(); return keyValue; }