// IErlModule findIncludeFromProject(IErlProject project, String
// includeName, String includePath, Scope scope) throws ErlModelException;
@Test
public void findIncludeFromProject() throws Exception {
File externalIncludeFile = null;
final IErlProject aProject = project;
final IProject workspaceProject = aProject.getWorkspaceProject();
final IProject[] referencedProjects = workspaceProject.getReferencedProjects();
final Collection<IPath> includeDirs = aProject.getProperties().getIncludeDirs();
// given
// a project with an external include and an internal include and a
// referenced project with an include
try {
final String xxHrl = "xx.hrl";
externalIncludeFile = createTmpFile(xxHrl,
"-record(rec2, {field, another=def}.");
final String externalIncludePath = externalIncludeFile.getAbsolutePath();
final IPath p = new Path(externalIncludePath).removeLastSegments(1);
final List<IPath> newIncludeDirs = Lists.newArrayList(includeDirs);
newIncludeDirs.add(p);
((ErlProject) aProject).setIncludeDirs(newIncludeDirs);
final IErlModule include = createInclude(aProject, "yy5.hrl",
"-define(Y, include).\n");
final IErlProject project1 = project2;
final IErlModule referencedInclude = createInclude(project1, "zz5.hrl",
"-define(Z, referenced).\n");
aProject.open(null);
// when
// looking for includes
final String xx = "xx";
final IErlModule x1 = model.findIncludeFromProject(aProject, xx, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule x2 = model.findIncludeFromProject(aProject, xx, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule x3 = model.findIncludeFromProject(aProject, xx, null,
IErlElementLocator.Scope.REFERENCED_PROJECTS);
final String yy = "yy5";
final IErlModule y1 = model.findIncludeFromProject(aProject, yy, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule y2 = model.findIncludeFromProject(aProject, yy, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule y3 = model.findIncludeFromProject(aProject, yy, null,
IErlElementLocator.Scope.REFERENCED_PROJECTS);
final IErlModule y4 = model.findIncludeFromProject(project1, yy, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule y5 = model.findIncludeFromProject(project1, yy, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule y6 = model.findIncludeFromProject(project1, yy, null,
IErlElementLocator.Scope.REFERENCED_PROJECTS);
final String zz = "zz5";
final IErlModule z1 = model.findIncludeFromProject(aProject, zz, null,
IErlElementLocator.Scope.PROJECT_ONLY);
final IErlModule z2 = model.findIncludeFromProject(aProject, zz, null,
IErlElementLocator.Scope.ALL_PROJECTS);
final IErlModule z3 = model.findIncludeFromProject(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.findIncludeFromProject(aProject, zz, null,
IErlElementLocator.Scope.PROJECT_ONLY);