use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class IErlProjectTest method getExternalIncludesString.
// String getExternalIncludesString();
@Test
public void getExternalIncludesString() throws Exception {
final IErlProject aProject = ErlModelTestBase.projects[0];
final String externalIncludesString = aProject.getProperties().getExternalIncludes();
try {
final String s = "/tjo";
((ErlProject) aProject).setExternalIncludesFile(s);
assertEquals(s, aProject.getProperties().getExternalIncludes());
} finally {
((ErlProject) aProject).setExternalIncludesFile(externalIncludesString);
}
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class IErlProjectTest method setSourceDirs.
// void setSourceDirs(Collection<IPath> sourceDirs)
// throws BackingStoreException;
@Test
public void setSourceDirs() throws Exception {
final IErlProject aProject = ErlModelTestBase.projects[0];
final Collection<IPath> sourceDirs = aProject.getProperties().getSourceDirs();
try {
// given
// an Erlang project and a module
final IPath srcxPath = new Path("srcx");
final List<IPath> srcxDirs = Lists.newArrayList(srcxPath);
aProject.open(null);
// when
// setting source dirs so the module is on source path
final Collection<IErlModule> modules = aProject.getModules();
((ErlProject) aProject).setSourceDirs(srcxDirs);
aProject.open(null);
final Collection<IErlModule> srcxModules = aProject.getModules();
((ErlProject) aProject).setSourceDirs(sourceDirs);
aProject.open(null);
final Collection<IErlModule> modulesAgain = aProject.getModules();
// then
// the it should be returned, but not otherwise
assertEquals(0, srcxModules.size());
assertEquals(1, modules.size());
assertEquals(module, modules.iterator().next());
assertEquals(1, modulesAgain.size());
assertEquals(module, modulesAgain.iterator().next());
} finally {
((ErlProject) aProject).setSourceDirs(sourceDirs);
}
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class IErlProjectTest method setProperties.
// TODO check more properties than source dirs property
@Test
public void setProperties() throws Exception {
final IErlProject aProject = ErlModelTestBase.projects[0];
final Collection<IPath> sourceDirs = aProject.getProperties().getSourceDirs();
try {
final ErlangProjectProperties properties = aProject.getProperties();
final IPath srcx = new Path("srcx");
properties.setSourceDirs(Lists.newArrayList(srcx));
aProject.setProperties(properties);
final Collection<IPath> sourceDirs2 = aProject.getProperties().getSourceDirs();
assertEquals(1, sourceDirs2.size());
assertEquals(srcx, sourceDirs2.iterator().next());
} finally {
((ErlProject) aProject).setSourceDirs(sourceDirs);
}
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class IErlProjectTest method getProjectReferences_closedProject.
public void getProjectReferences_closedProject() throws Exception {
final IErlProject erlProject = ErlModelTestBase.projects[0];
final IProject aProject = erlProject.getWorkspaceProject();
try {
aProject.close(null);
erlProject.getReferencedProjects();
} finally {
if (!aProject.isOpen()) {
aProject.open(null);
}
}
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class ModelUtilsTest method findExternalModuleFromPath.
@Test
public void findExternalModuleFromPath() throws Exception {
File externalFile = null;
IErlProject project = null;
try {
// given
// an erlang project and an external file not in any project
project = ErlideTestUtils.createErlProject("testproject");
final String externalFileName = "external2.erl";
externalFile = ErlideTestUtils.createTmpFile(externalFileName, "-module(external2).\nf([_ | _]=L ->\n atom_to_list(L).\n");
final String absolutePath = externalFile.getAbsolutePath();
final String externalsFileName = "x.erlidex";
final File externalsFile = ErlideTestUtils.createTmpFile(externalsFileName, absolutePath);
((ErlProject) project).setExternalModulesFile(externalsFile.getAbsolutePath());
project.open(null);
// when
// looking for it
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule module = modelFindService.findModule(model, null, null, absolutePath, IErlElementLocator.Scope.ALL_PROJECTS);
// then
// we should find it
assertThat(module).isNotNull();
assertThat(externalFileName).isEqualTo(module.getName());
} finally {
if (externalFile != null && externalFile.exists()) {
externalFile.delete();
}
if (project != null) {
ErlideTestUtils.deleteProject(project);
}
}
}
Aggregations