String (@NotNull PsiElement match, int start, int end) { if (match instanceof PsiIdentifier) { final PsiElement parent = match.getParent(); if (parent instanceof PsiJavaCodeReferenceElement referenceElement && !(parent instanceof PsiExpression)) { final String text = referenceElement.getText(); if (end != -1) { return text.substring(start, end); } final PsiReferenceParameterList parameterList = referenceElement.getParameterList(); if (parameterList != null) { // get text without type parameters return text.substring(start, parameterList.getStartOffsetInParent()); } return text; } } final String matchText = match.getText(); if (start == 0 && end == -1) return matchText; return matchText.substring(start, (end == -1) ? matchText.length() : end); }