Module deeModule = DToolClient.getDefaultModuleCache().getExistingParsedModuleNode(filePath);
ASTNode node = ASTNodeFinder.findElement(deeModule, offset);
if(node instanceof DefSymbol) {
DefUnit defUnit = ((DefSymbol) node).getDefUnit();
try {
IMember modelElement = DeeModelEngine.findCorrespondingModelElement(defUnit, sourceModule);
return modelElement == null ? null : new IModelElement[] { modelElement };
} catch (ModelException e) {
return null;
}
}
if(!(node instanceof Reference)) {
return new IModelElement[0];
}
Reference ref = (Reference) node;
IModuleResolver moduleResolver = DToolClient_Bad.getResolverFor(filePath);
Collection<INamedElement> defElements = ref.findTargetDefElements(moduleResolver, false);
// We assume namespace Parent is the same
if(defElements == null) {
return new IModelElement[0];
}
ArrayList<IModelElement> list = new ArrayList<IModelElement>();
for (INamedElement defElement : defElements) {
DefUnit defUnit = defElement.resolveDefUnit();
IMember modelElement = getModelElement(defUnit, sourceModule);
if(modelElement != null) {
list.add(modelElement);
}
}