new DeeSearchEngineTestUtils.ElementsAndDefUnitVisitor() {
@Override
protected void visitNode(ASTNode node, ISourceModule sourceModule) {
if(node instanceof Reference) {
Reference reference = (Reference) node;
Path filePath = DToolClient_Bad.getFilePathOrNull(sourceModule);
if(filePath == null) {
return;
}
IModuleResolver mr = DToolClient_Bad.getResolverFor(filePath);
Collection<INamedElement> targetDefElements = reference.findTargetDefElements(mr, false);
if(targetDefElements == null || targetDefElements.isEmpty()) {
return;
}
for (INamedElement defElement : targetDefElements) {
DefUnit defUnit = defElement.resolveDefUnit();
if(defUnit == null) {
continue;
}
Module moduleNode = defUnit.getModuleNode();
if(moduleNode == null) {
continue; // consider this case more
}
ISourceModule defUnitSrcModule = findSourceModule(moduleNode, searchProj);
ArrayList<Integer> nodeTreePath = DeeSearchEngineTestUtils.getNodeTreePath(defUnit);
Pair<ISourceModule, ?> key = Pair.create(defUnitSrcModule, nodeTreePath);
if(defUnitToReferencesMap.get(key) == null) {
defUnitToReferencesMap.put(key, new HashSet<Reference>());
}
defUnitToReferencesMap.get(key).add(reference);
}
}
}
}.visitElementsAndNodes(getSrcFolder(searchProj, "srcA"), 10);
for (Pair<ISourceModule, ?> key : defUnitToReferencesMap.keySet()) {
ISourceModule sourceModule = key.getFirst();
ArrayList<Integer> nodeTreePath = blindCast(key.getSecond());
Path filePath = DLTKUtils.getFilePath(sourceModule);
ParsedModule parseModule = DToolClient.getDefaultModuleCache().getParsedModuleOrNull(filePath);
Module deeModule = parseModule == null ? null : parseModule.module;
ASTNode node = DeeSearchEngineTestUtils.getNodeFromPath(deeModule, nodeTreePath);