Source:
<code>public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) { List<ResolvedMethodDeclaration> candidateMethods = typeDeclaration.getDeclaredMethods().stream() .filter(m -> m.getName().equals(name)) .filter(m -> !staticOnly || m.isStatic()) .collect(Collectors.toList()); if (!Object.class.getCanonicalName().equals(typeDeclaration.getQualifiedName())) { for (ResolvedReferenceType ancestor : typeDeclaration.getAncestors(true)) { if (typeDeclaration != ancestor.getTypeDeclaration()) { candidateMethods.addAll(ancestor.getAllMethodsVisibleToInheritors() .stream() .filter(m -> m.getName().equals(name)) .collect(Collectors.toList())); SymbolReference<ResolvedMethodDeclaration> res = MethodResolutionLogic .solveMethodInType(ancestor.getTypeDeclaration(), name, argumentsTypes, staticOnly); if (res.isSolved()) { candidateMethods.add(res.getCorrespondingDeclaration()); } } } } if (candidateMethods.isEmpty()) { <START> Optional<CompilationUnitContext> cu = findCompilationUnitContext(); <END> if (cu.isPresent()) { SymbolReference<ResolvedMethodDeclaration> parentSolution = cu.get().solveMethod(name, argumentsTypes, staticOnly); if (parentSolution.isSolved()) { candidateMethods.add(parentSolution.getCorrespondingDeclaration()); } } } if (candidateMethods.isEmpty() && typeDeclaration.isInterface()) { SymbolReference<ResolvedMethodDeclaration> res = MethodResolutionLogic.solveMethodInType(new ReflectionClassDeclaration(Object.class, typeSolver), name, argumentsTypes, false); if (res.isSolved()) { candidateMethods.add(res.getCorrespondingDeclaration()); } } return MethodResolutionLogic.findMostApplicable(candidateMethods, name, argumentsTypes, typeSolver); }</code><technical_language>minor worth blocking this over, mind renaming this cuCtx similar a compilation unit please</technical_language>

Target:
public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) { List<ResolvedMethodDeclaration> candidateMethods = typeDeclaration.getDeclaredMethods().stream() .filter(m -> m.getName().equals(name)) .filter(m -> !staticOnly || m.isStatic()) .collect(Collectors.toList()); if (!Object.class.getCanonicalName().equals(typeDeclaration.getQualifiedName())) { for (ResolvedReferenceType ancestor : typeDeclaration.getAncestors(true)) { if (typeDeclaration != ancestor.getTypeDeclaration()) { candidateMethods.addAll(ancestor.getAllMethodsVisibleToInheritors() .stream() .filter(m -> m.getName().equals(name)) .collect(Collectors.toList())); SymbolReference<ResolvedMethodDeclaration> res = MethodResolutionLogic .solveMethodInType(ancestor.getTypeDeclaration(), name, argumentsTypes, staticOnly); if (res.isSolved()) { candidateMethods.add(res.getCorrespondingDeclaration()); } } } } if (candidateMethods.isEmpty() && typeDeclaration.isInterface()) { SymbolReference<ResolvedMethodDeclaration> res = MethodResolutionLogic.solveMethodInType(new ReflectionClassDeclaration(Object.class, typeSolver), name, argumentsTypes, false); if (res.isSolved()) { candidateMethods.add(res.getCorrespondingDeclaration()); } } return MethodResolutionLogic.findMostApplicable(candidateMethods, name, argumentsTypes, typeSolver); }