boolean (@NotNull UMethod method, @NotNull Set<UMethod> processedMethods) { UExpression body = method.getUastBody(); if (body == null) return false; Ref<Boolean> violates = Ref.create(Boolean.FALSE); body.accept(new AbstractUastVisitor() { @Override public boolean visitQualifiedReferenceExpression(@NotNull UQualifiedReferenceExpression node) { if (violates.get()) return SKIP_CHILDREN; UExpression receiver = node.getReceiver(); if (receiver instanceof UResolvable resolvable) { UElement resolvedUElement = UastContextKt.toUElement(resolvable.resolve()); if (resolvedUElement != null && isViolation(resolvedUElement)) { violates.set(Boolean.TRUE); return SKIP_CHILDREN; } } return super.visitQualifiedReferenceExpression(node); } @Override public boolean visitSimpleNameReferenceExpression(@NotNull USimpleNameReferenceExpression node) { if (violates.get()) return SKIP_CHILDREN; UElement resolvedUElement = UastContextKt.toUElement(node.resolve()); if (resolvedUElement != null && isViolation(resolvedUElement)) { violates.set(Boolean.TRUE); return SKIP_CHILDREN; } return super.visitSimpleNameReferenceExpression(node); } @Override public boolean visitCallExpression(@NotNull UCallExpression node) { if (violates.get()) return SKIP_CHILDREN; if (node.getKind() == UastCallKind.METHOD_CALL) { UElement resolvedUElement = UastContextKt.toUElement(node.resolve()); if (resolvedUElement != null && isViolation(resolvedUElement)) { violates.set(Boolean.TRUE); return SKIP_CHILDREN; } } return super.visitCallExpression(node); } private boolean isViolation(@NotNull UElement uElement) { if (uElement instanceof UVariable resolvedUVariable) { if (!isStaticField(resolvedUVariable) && isContextDependentType((resolvedUVariable).getType())) { return true; } } else if (uElement instanceof UMethod calledMethod) { UClass callingContainingClass = UastContextKt.getUastParentOfType(method.getSourcePsi(), UClass.class, true); UClass calledMethodClass = UastContextKt.getUastParentOfType(calledMethod.getSourcePsi(), UClass.class, true); if (calledMethodClass != null && callingContainingClass != null && (callingContainingClass.getSourcePsi() == calledMethodClass.getSourcePsi() || callingContainingClass.getJavaPsi().isInheritor(calledMethodClass.getJavaPsi(), true))) { if (doesMethodViolate(calledMethod, processedMethods)) { return true; } } } return false; } private static boolean isStaticField(@NotNull UVariable uVariable) { if (!(uVariable instanceof UField)) return false; PsiElement variableJavaPsi = uVariable.getJavaPsi(); if (variableJavaPsi instanceof PsiField field) { return field.hasModifierProperty(PsiModifier.STATIC); } return false; } }); return violates.get(); }