String (@NotNull CharSequence fileText, @NotNull HighlighterIterator iterator) { final IElementType tokenType = iterator.getTokenType(); String name = null; if (tokenType == XmlTokenType.XML_START_TAG_START) { iterator.advance(); IElementType tokenType1 = iterator.atEnd() ? null : iterator.getTokenType(); boolean wasWhiteSpace = false; if (isWhitespace(tokenType1)) { wasWhiteSpace = true; iterator.advance(); tokenType1 = iterator.atEnd() ? null : iterator.getTokenType(); } if (tokenType1 == XmlTokenType.XML_TAG_NAME || tokenType1 == XmlTokenType.XML_NAME ) { name = fileText.subSequence(iterator.getStart(), iterator.getEnd()).toString(); } if (wasWhiteSpace) iterator.retreat(); iterator.retreat(); } else if (tokenType == XmlTokenType.XML_TAG_END || tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END) { int balance = 0; int count = 0; IElementType tokenType1 = iterator.getTokenType(); while (balance >=0) { iterator.retreat(); count++; if (iterator.atEnd()) break; tokenType1 = iterator.getTokenType(); if (tokenType1 == XmlTokenType.XML_TAG_END || tokenType1 == XmlTokenType.XML_EMPTY_ELEMENT_END) { balance++; } else if (tokenType1 == XmlTokenType.XML_TAG_NAME) { balance--; } } if (tokenType1 == XmlTokenType.XML_TAG_NAME) { name = fileText.subSequence(iterator.getStart(), iterator.getEnd()).toString(); } while (count-- > 0) iterator.advance(); } return name; }