final JsonArray<CodeGraphProposalImpl> zeroBoundary,
JsonArray<CodeGraphProposalImpl> epsilonBoundary, JsonStringSet visited) {
visited.add(getFullId(fileData, root));
final JsonArray<CodeBlockAssociation> queue = fileData.getOutgoingLinks(root).copy();
while (!queue.isEmpty()) {
CodeBlockAssociation link = queue.splice(0, 1).pop();
FileIndex targetFileData = fileIdToData.get(link.getTargetFileId());
if (targetFileData == null) {
continue;
}
CodeBlock targetCodeBlock = targetFileData.findCodeBlock(link.getTargetLocalId());
if (targetCodeBlock == null) {
continue;
}
final String targetFqname = targetFileData.getFqname(targetCodeBlock);
if (targetFqname == null) {
if (targetCodeBlock.getBlockType() != CodeBlock.Type.VALUE_FILE) {
throw new IllegalStateException(
"type=" + CodeBlock.Type.valueOf(targetCodeBlock.getBlockType()));
}
continue;
}
String fullTargetId = getFullId(targetFileData, targetCodeBlock);
if (visited.contains(fullTargetId)) {
continue;
}
visited.add(fullTargetId);
// We have found a CodeBlock which is a target of the concrete link.
// We want to match children of this code block against the query,
// but the problem is that the children may be defined in another file
// or can even be spread over many files (which is the case in JS where
// one can add a method to Document.prototype from anywhere).
// So we need to run a tree query to find all code blocks with the
// same fqname (called representatives below).
if (link.getIsRootAssociation()) {
epsilonBoundary.add(new CodeGraphProposalImpl(
targetCodeBlock, targetFqname, targetFileData));
} else {
final JsonArray<CodeGraphProposalImpl> fqnameRepresentatives =
JsonCollections.createArray();