String (@NotNull PsiElement element) { String text; if (element instanceof PsiReceiverParameter) { text = ((PsiReceiverParameter)element).getIdentifier().getText(); } else if (element instanceof PsiNamedElement) { text = ((PsiNamedElement)element).getName(); } else if (element instanceof PsiAnnotation) { final PsiJavaCodeReferenceElement referenceElement = ((PsiAnnotation)element).getNameReferenceElement(); text = referenceElement == null ? null : referenceElement.getText(); } else if (element instanceof PsiNameValuePair) { text = ((PsiNameValuePair)element).getName(); } else { text = element.getText(); if (StringUtil.startsWithChar(text, '@')) { text = text.substring(1); } if (StringUtil.endsWithChar(text, ';')) text = text.substring(0, text.length() - 1); else if (element instanceof PsiExpressionStatement) { final int i = text.indexOf(';'); if (i != -1) text = text.substring(0, i); } } if (text==null) text = element.getText(); return text; }