YAMLKeyValue (@NotNull PsiElement element) { if (PsiUtilCore.getElementType(element.getParent()) != YAMLElementTypes.MAPPING) { // TODO: RUBY-22437 support JSON-like mappings return null; } boolean eolMet = false; PsiElement cur; for (cur = element; cur != null; cur = cur.getPrevSibling()) { if (!YAMLElementTypes.BLANK_ELEMENTS.contains(PsiUtilCore.getElementType(cur))) { break; } if (PsiUtilCore.getElementType(cur) == YAMLTokenTypes.EOL) { eolMet = true; } } if (eolMet && PsiUtilCore.getElementType(cur) == YAMLElementTypes.KEY_VALUE_PAIR) { return (YAMLKeyValue)cur; } return null; }