@Override
public Object[] getChildren(final Object parentElement) {
if (parentElement instanceof String) {
return new Object[0];
}
final IErlFunction parent = (IErlFunction) parentElement;
final FunctionRef ref = new FunctionRef(parent);
final FunctionRef[] children = xrefService.functionUse(ref);
if (children == null) {
return new Object[0];
}
if (parentElement == input && children.length == 0) {
// TODO ErlangXref should cache _all_ projects added to it
return new Object[] { "<no callers from project "
+ ErlangEngine
.getInstance()
.getModelUtilService()
.getProject(
ErlangEngine.getInstance().getModelUtilService()
.getModule(parent)).getName() + ">" };
}
final List<IErlFunction> result = new ArrayList<IErlFunction>();
for (final FunctionRef r : children) {
try {
final IErlFunction fun = ErlangEngine.getInstance().getModel()
.findFunction(r);
if (fun != null) {
result.add(fun);
}
} catch (final ErlModelException e) {