boolean (@NotNull Processor<? super SliceUsage> processor, @NotNull PsiSubstitutor parentSubstitutor, @Nullable PsiClass qualifierClass, PsiMethod methodCalled, @Nullable PsiType parentType, @NotNull JavaSliceBuilder builder) { Collection<PsiMethod> overrides = new HashSet<>(); SearchScope scope = builder.getSearchScope(); if (qualifierClass != null && qualifierClass != methodCalled.getContainingClass()) { scope = JavaTargetElementEvaluator.getHierarchyScope(qualifierClass, scope, false); } overrides.addAll(OverridingMethodsSearch.search(methodCalled, scope, true).findAll()); overrides.add(methodCalled); final boolean[] result = {true}; for (PsiMethod override : overrides) { if (!result[0]) break; if (override instanceof PsiCompiledElement) { override = (PsiMethod)override.getNavigationElement(); } if (!builder.getParent().getScope().contains(PsiUtil.preferCompiledElement(override))) continue; Language language = override.getLanguage(); if (language != JavaLanguage.INSTANCE) { builder.process(override, processor); continue; } final PsiCodeBlock body = override.getBody(); if (body == null) continue; PsiSubstitutor origSubstitutor = builder.getSubstitutor(); final PsiSubstitutor s = methodCalled == override ? origSubstitutor : MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodCalled.getSignature(origSubstitutor), override.getSignature(origSubstitutor)); final PsiSubstitutor superSubstitutor = s == null ? parentSubstitutor : s; body.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitClass(@NotNull PsiClass aClass) {} @Override public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) {} @Override public void visitReturnStatement(final @NotNull PsiReturnStatement statement) { PsiExpression returnValue = statement.getReturnValue(); if (returnValue == null) return; PsiType right = superSubstitutor.substitute(superSubstitutor.substitute(returnValue.getType())); if (right == null || parentType != null && !TypeConversionUtil.isAssignable(parentType, right)) return; if (!builder.process(returnValue, processor)) { stopWalking(); result[0] = false; } } }); } return result[0]; }