int (@NotNull PsiElement element) { if (element instanceof YAMLBlockMappingImpl) { try { element = ((YAMLBlockMappingImpl)element).getFirstKeyValue(); } catch (IllegalStateException e) { // Spring Boot plug-in modifies PSI-tree into invalid state // This is workaround over EA-133507 IDEA-210113 if (!e.getMessage().equals(YAMLBlockMappingImpl.EMPTY_MAP_MESSAGE)) { throw e; } else { Logger.getInstance(YAMLUtil.class).warn(YAMLBlockMappingImpl.EMPTY_MAP_MESSAGE); } } } int offset = element.getTextOffset(); PsiElement currentElement = element; while (currentElement != null) { final IElementType type = currentElement.getNode().getElementType(); if (YAMLElementTypes.EOL_ELEMENTS.contains(type)) { return offset - currentElement.getTextOffset() - currentElement.getTextLength(); } currentElement = PsiTreeUtil.prevLeaf(currentElement); } return offset; }