Source:
<code>private Map<String, List<String>> getCallsToDependencies(String mainDescriptor) { Map<String, List<String>> map = new HashMap<>(); try (InputStream stream = IOUtils.toInputStream(mainDescriptor, StandardCharsets.UTF_8)) { GroovyRecognizer make = GroovyRecognizer.make(new GroovyLexer(stream)); make.compilationUnit(); GroovySourceAST ast = (GroovySourceAST)make.getAST(); List<GroovySourceAST> processList = getSubtreesOfKeyword(ast, "process"); Map<String, List<String>> processNameToInputChannels = new HashMap<>(); Map<String, List<String>> processNameToOutputChannels = new HashMap<>(); <START> for (GroovySourceAST processAST : processList) { <END> String processName = getProcessValue(processAST); List<String> inputs = getInputDependencyList(processAST); processNameToInputChannels.put(processName, inputs); List<String> outputs = getOutputDependencyList(processAST); processNameToOutputChannels.put(processName, outputs); } for (String processName : processNameToInputChannels.keySet()) { List<String> dependencies = new ArrayList<>(); for (String channelRead : processNameToInputChannels.get(processName)) { for (String dependentProcessName : processNameToOutputChannels.keySet()) { for (String channelWrite : processNameToOutputChannels.get(dependentProcessName)) { if (Objects.equals(channelRead, channelWrite)) { dependencies.add(dependentProcessName); break; } } } } map.put(processName, dependencies); } } catch (IOException | TokenStreamException | RecognitionException e) { LOG.warn("could not parse", e); } return map; }</code><technical_language>cleaner lambdas, inputs, outputs</technical_language>

Target:
private Map<String, List<String>> getCallsToDependencies(String mainDescriptor) { Map<String, List<String>> map = new HashMap<>(); try (InputStream stream = IOUtils.toInputStream(mainDescriptor, StandardCharsets.UTF_8)) { GroovyRecognizer make = GroovyRecognizer.make(new GroovyLexer(stream)); make.compilationUnit(); GroovySourceAST ast = (GroovySourceAST)make.getAST(); List<GroovySourceAST> processList = getSubtreesOfKeyword(ast, "process"); Map<String, List<String>> processNameToInputChannels = new HashMap<>(); Map<String, List<String>> processNameToOutputChannels = new HashMap<>(); processList.forEach((GroovySourceAST processAST) -> { String processName = getProcessValue(processAST); List<String> inputs = getInputDependencyList(processAST); processNameToInputChannels.put(processName, inputs); List<String> outputs = getOutputDependencyList(processAST); processNameToOutputChannels.put(processName, outputs); }); processNameToInputChannels.keySet().forEach((String processName) -> { List<String> dependencies = new ArrayList<>(); processNameToInputChannels.get(processName).forEach((String channelRead) -> { processNameToOutputChannels.keySet().forEach((String dependentProcessName) -> { Optional<String> temp = processNameToOutputChannels.get(dependentProcessName) .stream() .filter(channelWrite -> Objects.equals(channelRead, channelWrite)) .findFirst(); if (temp.isPresent()) { dependencies.add(dependentProcessName); } }); }); map.put(processName, dependencies); }); } catch (IOException | TokenStreamException | RecognitionException e) { LOG.warn("could not parse", e); } return map; }