TextRange (@NotNull PsiElement container) { int start = container.getTextRange().getStartOffset(); if (container instanceof PyFunction) { PyParameterList parameterList = ((PyFunction)container).getParameterList(); return new TextRange(start, parameterList.getTextRange().getEndOffset()); } if (container instanceof PyClass) { PyArgumentList argumentList = ((PyClass)container).getSuperClassExpressionList(); if (argumentList != null) { return new TextRange(start, argumentList.getTextRange().getEndOffset()); } ASTNode nameNode = ((PyClass)container).getNameNode(); if (nameNode != null) { return new TextRange(start, nameNode.getStartOffset() + nameNode.getTextLength()); } } return container.getTextRange(); }