PsiElement psiElement = sourceElement.get();
if (psiElement == null || !psiElement.isValid()) {
return false;
}
ErlangFunction function = PsiTreeUtil.getParentOfType(psiElement, ErlangFunction.class);
PsiFile containingFile = psiElement.getContainingFile();
if (!(containingFile instanceof ErlangFile) || function == null ||
ErlangPsiImplUtil.isEunitTestFunction(function) ||
ErlangPsiImplUtil.isPrivateFunction(containingFile, function)) {
return false;
}
Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
VirtualFile vFile = containingFile.getVirtualFile();
if (vFile == null) return false;
String moduleName = vFile.getNameWithoutExtension();
String functionName = function.getName();
configuration.setModuleAndFunction(moduleNameAndFunction(moduleName, functionName));
configuration.setName(moduleName + "." + functionName);
if (module != null) {
configuration.setModule(module);