public static boolean isClassReference(GrReferenceExpression ref) { GrExpression qualifier = ref.getQualifier(); return "class".equals(ref.getReferenceName()) && qualifier instanceof GrReferenceExpression && ((GrReferenceExpression) qualifier).resolve() instanceof PsiClass && !PsiUtil.isThisReference(qualifier); }
private static boolean isPropertyAccessInStaticMethod(GrReferenceExpression referenceExpression) { if (referenceExpression.getParent() instanceof GrMethodCall || referenceExpression.getQualifier() != null) return false; GrMember context = PsiTreeUtil.getParentOfType( referenceExpression, GrMember.class, true, GrClosableBlock.class); return (context instanceof GrMethod || context instanceof GrClassInitializer) && context.hasModifierProperty(STATIC); }
private static void registerStaticImportFix( @NotNull GrReferenceExpression referenceExpression, @Nullable HighlightInfo info, @Nullable final HighlightDisplayKey key) { final String referenceName = referenceExpression.getReferenceName(); if (StringUtil.isEmpty(referenceName)) return; if (referenceExpression.getQualifier() != null) return; QuickFixAction.registerQuickFixAction( info, new GroovyStaticImportMethodFix((GrMethodCall) referenceExpression.getParent()), key); }
private static boolean shouldHighlightAsUnresolved( @NotNull GrReferenceExpression referenceExpression) { if (GrHighlightUtil.isDeclarationAssignment(referenceExpression)) return false; GrExpression qualifier = referenceExpression.getQualifier(); if (qualifier != null && qualifier.getType() == null && !isRefToPackage(qualifier)) return false; if (qualifier != null && referenceExpression.getDotTokenType() == GroovyTokenTypes.mMEMBER_POINTER && referenceExpression.multiResolve(false).length > 0) { return false; } if (!GroovyUnresolvedHighlightFilter.shouldHighlight(referenceExpression)) return false; CollectConsumer<PomTarget> consumer = new CollectConsumer<PomTarget>(); for (PomDeclarationSearcher searcher : PomDeclarationSearcher.EP_NAME.getExtensions()) { searcher.findDeclarationsAt(referenceExpression, 0, consumer); if (!consumer.getResult().isEmpty()) return false; } return true; }