Search in sources :

Example 51 with IErlProject

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);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlProject(org.erlide.engine.internal.model.root.ErlProject) IErlProject(org.erlide.engine.model.root.IErlProject) Test(org.junit.Test)

Example 52 with IErlProject

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);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ErlProject(org.erlide.engine.internal.model.root.ErlProject) IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) Test(org.junit.Test)

Example 53 with IErlProject

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);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) ErlProject(org.erlide.engine.internal.model.root.ErlProject) IErlProject(org.erlide.engine.model.root.IErlProject) Test(org.junit.Test)

Example 54 with IErlProject

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);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IProject(org.eclipse.core.resources.IProject)

Example 55 with IErlProject

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);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlProject(org.erlide.engine.internal.model.root.ErlProject) IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) File(java.io.File) Test(org.junit.Test)

Aggregations

IErlProject (org.erlide.engine.model.root.IErlProject)123 IErlModule (org.erlide.engine.model.root.IErlModule)57 Test (org.junit.Test)47 IPath (org.eclipse.core.runtime.IPath)30 IProject (org.eclipse.core.resources.IProject)29 ErlProject (org.erlide.engine.internal.model.root.ErlProject)25 File (java.io.File)19 Path (org.eclipse.core.runtime.Path)16 CoreException (org.eclipse.core.runtime.CoreException)13 ErlModelException (org.erlide.engine.model.ErlModelException)13 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)13 IErlModel (org.erlide.engine.model.root.IErlModel)13 ArrayList (java.util.ArrayList)11 IErlElement (org.erlide.engine.model.IErlElement)10 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 HashSet (java.util.HashSet)7 IProjectDescription (org.eclipse.core.resources.IProjectDescription)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)6 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)6