TextRange (@NotNull CompositePsiElement refElement) { TreeElement nameChild = (TreeElement)refElement.findChildByRole(ChildRole.REFERENCE_NAME); if (nameChild == null) { TreeElement dot = (TreeElement)refElement.findChildByRole(ChildRole.DOT); if (dot == null) { throw new IllegalStateException(refElement.toString()); } return TextRange.from(dot.getStartOffsetInParent() + dot.getTextLength(), 0); } return TextRange.from(nameChild.getStartOffsetInParent(), nameChild.getTextLength()); }