// String modulePath, Scope scope) throws ErlModelException;
@Test
public void findModuleFromProject() throws Exception {
File externalModuleFile = null;
File externalsFile = null;
final IErlProject aProject = project;
final IProject workspaceProject = aProject.getWorkspaceProject();
final IProject[] referencedProjects = workspaceProject.getReferencedProjects();
final String externalModulesString = aProject.getProperties()
.getExternalModules();
// given
// a project with an external module and an internal module and a
// referenced project with a module
try {
final String xxErl = "xx6.erl";
externalModuleFile = createTmpFile(xxErl, "-module(xx6).\n");
final String externalModulePath = externalModuleFile.getAbsolutePath();
externalsFile = createTmpFile(XX_ERLIDEX, externalModulePath);
((ErlProject) aProject).setExternalModulesFile(externalsFile
.getAbsolutePath());
final IErlModule aModule = createModule(aProject, "yy6.erl",
"-module(yy6).\n");
final IErlProject project1 = project2;
final IErlModule referencedModule = createModule(project1, "zz6.erl",
"-module(zz6).\n");
aProject.open(null);
// when
// looking for modules
final String xx = "xx6";
final IErlModule x1 = model.findModuleFromProject(aProject, xx, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule x2 = model.findModuleFromProject(aProject, xx, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule x3 = model.findModuleFromProject(aProject, xx, null,
IErlElementLocator.Scope.REFERENCED_PROJECTS);
final String yy = "yy6";
final IErlModule y1 = model.findModuleFromProject(aProject, yy, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule y2 = model.findModuleFromProject(aProject, yy, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule y3 = model.findModuleFromProject(aProject, yy, null,
IErlElementLocator.Scope.REFERENCED_PROJECTS);
final IErlModule y4 = model.findModuleFromProject(project1, yy, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule y5 = model.findModuleFromProject(project1, yy, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule y6 = model.findModuleFromProject(project1, yy, null,
IErlElementLocator.Scope.REFERENCED_PROJECTS);
final String zz = "zz6";
final IErlModule z1 = model.findModuleFromProject(aProject, zz, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule z2 = model.findModuleFromProject(aProject, zz, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule z3 = model.findModuleFromProject(aProject, zz, null,
IErlElementLocator.Scope.REFERENCED_PROJECTS);
final IProjectDescription description = workspaceProject.getDescription();
description.setReferencedProjects(new IProject[] { project1
.getWorkspaceProject() });
workspaceProject.setDescription(description, null);
aProject.open(null);
final IErlModule z4 = model.findModuleFromProject(aProject, zz, null,
IErlElementLocator.Scope.PROJECT_ONLY);