TextRange () { final ASTNode nameElement = getNameElement(); if (nameElement == null){ return TextRange.EMPTY_RANGE; } int colon = getPrefixIndex(nameElement.getText()) + 1; if (myStartTagFlag) { final int parentOffset = nameElement.getStartOffsetInParent(); return new TextRange(parentOffset + colon, parentOffset + nameElement.getTextLength()); } else { final PsiElement element = getElement(); if (element == myNameElement) return new TextRange(colon, myNameElement.getTextLength()); final int elementLength = element.getTextLength(); int diffFromEnd = 0; for(ASTNode node = element.getNode().getLastChildNode(); node != nameElement && node != null; node = node.getTreePrev()) { diffFromEnd += node.getTextLength(); } final int nameEnd = elementLength - diffFromEnd; return new TextRange(nameEnd - nameElement.getTextLength() + colon, nameEnd); } }