boolean (final GrReferenceExpression ref) { GrExpression qualifier = ref.getQualifier(); if (qualifier instanceof GrReferenceExpression) { final PsiElement resolvedQualifier = ((GrReferenceExpression)qualifier).resolve(); return resolvedQualifier instanceof PsiClass || resolvedQualifier instanceof PsiPackage; } else { return qualifier == null; } }