PsiClass (@Nullable PsiAnnotationMemberValue targetValue) { if (targetValue instanceof PsiClassObjectAccessExpression) { PsiType type = ((PsiClassObjectAccessExpression)targetValue).getOperand().getType(); if (type instanceof PsiClassType) { return ((PsiClassType)type).resolve(); } } else if (targetValue instanceof GrReferenceExpression) { if ("class".equals(((GrReferenceExpression)targetValue).getReferenceName())) { GrExpression qualifier = ((GrReferenceExpression)targetValue).getQualifier(); if (qualifier instanceof GrReferenceExpression) { PsiElement resolved = ((GrReferenceExpression)qualifier).resolve(); if (resolved instanceof PsiClass) { return (PsiClass)resolved; } } } PsiElement resolved = ((GrReferenceExpression)targetValue).resolve(); if (resolved instanceof PsiClass) return (PsiClass)resolved; } return null; }