PsiClass () { final PsiElement classReferencesElement = getClassReferencesElement(); if (classReferencesElement != null) { final PsiReference[] references = classReferencesElement.getReferences(); if (references.length > 0) { final PsiElement psiElement = references[references.length - 1].resolve(); if (psiElement instanceof XmlAttributeValue) { final XmlTag beanTag = (XmlTag)psiElement.getParent().getParent(); XmlAttribute attribute = beanTag.getAttribute("class", null); if (attribute == null) attribute = beanTag.getAttribute("type", null); if (attribute != null) { final PsiReference[] classReferences = attribute.getValueElement().getReferences(); if (classReferences.length > 0) { final PsiElement classElement = classReferences[classReferences.length - 1].resolve(); if (classElement instanceof PsiClass) return (PsiClass)classElement; } } } else if (psiElement instanceof PsiClass) { return (PsiClass)psiElement; } else if (psiElement instanceof PsiVariable) { final PsiType type=((PsiVariable)psiElement).getType(); if (type instanceof PsiClassType) { return ((PsiClassType)type).resolve(); } } } } return null; }