Search in sources :

Example 6 with IErlFolder

use of org.erlide.engine.model.root.IErlFolder in project erlide_eclipse by erlang.

the class ErlProject method getModulesOrIncludes.

private static List<IErlModule> getModulesOrIncludes(final IProject project, final IErlElementLocator model, final Collection<IPath> dirs, final boolean getModules) throws ErlModelException {
    final List<IErlModule> result = Lists.newArrayList();
    for (final IPath dir : dirs) {
        final IFolder folder = project.getFolder(dir);
        final IErlElement element = model.findElement(folder, true);
        if (element instanceof IErlFolder) {
            final IErlFolder erlFolder = (IErlFolder) element;
            erlFolder.open(null);
            for (final IErlElement e : erlFolder.getChildrenOfKind(ErlElementKind.MODULE)) {
                if (e instanceof IErlModule) {
                    final IErlModule m = (IErlModule) e;
                    final boolean isModule = SourceKind.nameToModuleKind(m.getName()) != SourceKind.HRL;
                    if (isModule == getModules) {
                        result.add(m);
                    }
                }
            }
        }
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IPath(org.eclipse.core.runtime.IPath) IErlModule(org.erlide.engine.model.root.IErlModule) IErlFolder(org.erlide.engine.model.root.IErlFolder) IFolder(org.eclipse.core.resources.IFolder)

Example 7 with IErlFolder

use of org.erlide.engine.model.root.IErlFolder in project erlide_eclipse by erlang.

the class IParentTest method getChildWithResource.

// IErlElement getChildWithResource(IResource rsrc);
@Test
public void getChildWithResource() throws Exception {
    final IProject workspaceProject = project.getWorkspaceProject();
    final IErlModel model = ErlangEngine.getInstance().getModel();
    final IErlElement childWithResource = model.getChildWithResource(workspaceProject);
    final IResource resource = module.getResource();
    final IErlElement childWithResource2 = model.getChildWithResource(resource);
    final IErlFolder folder = (IErlFolder) project.getChildNamed("src");
    final IErlElement childWithResource3 = folder.getChildWithResource(resource);
    assertEquals(project, childWithResource);
    assertNull(childWithResource2);
    assertEquals(module, childWithResource3);
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlModel(org.erlide.engine.model.root.IErlModel) IErlFolder(org.erlide.engine.model.root.IErlFolder) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) Test(org.junit.Test)

Example 8 with IErlFolder

use of org.erlide.engine.model.root.IErlFolder in project erlide_eclipse by erlang.

the class IErlFolderTest method isSourcePathParent.

// boolean isSourcePathParent();
@Test
public void isSourcePathParent() throws Exception {
    final IErlFolder srcFolder2 = (IErlFolder) IErlFolderTest.project2.getChildNamed("src");
    final IErlFolder includeFolder2 = (IErlFolder) IErlFolderTest.project2.getChildNamed("include");
    final IErlFolder ebinFolder2 = (IErlFolder) IErlFolderTest.project2.getChildNamed("ebin");
    assertTrue(srcFolder2.isSourcePathParent());
    assertFalse(includeFolder2.isSourcePathParent());
    assertFalse(ebinFolder2.isSourcePathParent());
}
Also used : IErlFolder(org.erlide.engine.model.root.IErlFolder) Test(org.junit.Test)

Aggregations

IErlFolder (org.erlide.engine.model.root.IErlFolder)8 IErlElement (org.erlide.engine.model.IErlElement)5 IErlModule (org.erlide.engine.model.root.IErlModule)4 IFolder (org.eclipse.core.resources.IFolder)3 IResource (org.eclipse.core.resources.IResource)3 IFile (org.eclipse.core.resources.IFile)2 IParent (org.erlide.engine.model.IParent)2 IErlModel (org.erlide.engine.model.root.IErlModel)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 IContainer (org.eclipse.core.resources.IContainer)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IPath (org.eclipse.core.runtime.IPath)1 ErlFolder (org.erlide.engine.internal.model.root.ErlFolder)1 ErlModelException (org.erlide.engine.model.ErlModelException)1 ErlModelStatus (org.erlide.engine.model.ErlModelStatus)1 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)1 IErlProject (org.erlide.engine.model.root.IErlProject)1