Collection<GroovyResolveResult> (@NotNull GrReferenceExpression ref) { GrExpression qualifier = ref.getQualifier(); if (qualifier == null) { PsiClass aClass = PsiUtil.getContextClass(ref); if (aClass != null) { return Collections.singletonList(new ElementResolveResult<>(aClass)); } } else if (qualifier instanceof GrReferenceExpression) { GroovyResolveResult result = ((GrReferenceExpression)qualifier).advancedResolve(); PsiElement resolved = result.getElement(); if (resolved instanceof PsiClass && PsiUtil.hasEnclosingInstanceInScope((PsiClass)resolved, ref, false)) { return Collections.singletonList(result); } } return null; }