Search in sources :

Example 16 with IErlElement

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

the class ErlideTestUtils method initProjects.

public static void initProjects() throws CoreException {
    ErlideTestUtils.projects = Lists.newArrayList();
    final IErlModel model = ErlangEngine.getInstance().getModel();
    model.open(null);
    final List<IErlElement> children = model.getChildren();
    for (final IErlElement child : children) {
        if (child instanceof IErlProject) {
            final IErlProject project = (IErlProject) child;
            if (project.getName().startsWith("testproject")) {
                ErlideTestUtils.deleteProject(project);
            }
        }
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel)

Example 17 with IErlElement

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

the class ErlModel method create.

public IErlElement create(final IResource resource, final IParent parent) {
    if (resource == null) {
        return null;
    }
    final IErlElement e = findElement(resource);
    if (e != null) {
        return e;
    }
    final int type = resource.getType();
    switch(type) {
        case IResource.PROJECT:
            return createProject((IProject) resource);
        case IResource.FILE:
            return createFile((IFile) resource, parent);
        case IResource.FOLDER:
            return createFolder((IFolder) resource, parent);
        case IResource.ROOT:
            return createRoot((IWorkspaceRoot) resource);
        default:
            return null;
    }
// TODO should we make Erlidemodelevents and fire them?
}
Also used : IErlElement(org.erlide.engine.model.IErlElement)

Example 18 with IErlElement

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

the class ErlModel method getErlangProjects.

/**
 * @see IErlModel
 */
@Override
public Collection<IErlProject> getErlangProjects() throws ErlModelException {
    final Collection<IErlElement> list = getChildrenOfKind(ErlElementKind.PROJECT);
    final Collection<IErlProject> result = Lists.newArrayList();
    for (final IErlElement e : list) {
        result.add((IErlProject) e);
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlProject(org.erlide.engine.model.root.IErlProject)

Example 19 with IErlElement

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

the class ErlModelDeltaManager method mergeDeltas.

IErlElementDelta mergeDeltas(final Collection<IErlElementDelta> deltas) {
    synchronized (deltas) {
        if (deltas.isEmpty()) {
            return null;
        }
        if (deltas.size() == 1) {
            return deltas.iterator().next();
        }
        final Iterator<IErlElementDelta> iterator = deltas.iterator();
        final IErlElement cRoot = ErlangEngine.getInstance().getModel();
        final ErlElementDelta rootDelta = new ErlElementDelta(0, 0, cRoot);
        boolean insertedTree = false;
        while (iterator.hasNext()) {
            final ErlElementDelta delta = (ErlElementDelta) iterator.next();
            final IErlElement element = delta.getElement();
            if (cRoot.equals(element)) {
                final IErlElementDelta[] children = delta.getChildren(IErlElementDelta.ALL);
                for (final IErlElementDelta element0 : children) {
                    final ErlElementDelta projectDelta = (ErlElementDelta) element0;
                    rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta);
                    insertedTree = true;
                }
                final IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
                if (resourceDeltas != null) {
                    for (final IResourceDelta element0 : resourceDeltas) {
                        rootDelta.addResourceDelta(element0);
                        insertedTree = true;
                    }
                }
            } else {
                rootDelta.insertDeltaTree(element, delta);
                insertedTree = true;
            }
        }
        if (insertedTree) {
            return rootDelta;
        }
        return null;
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlElementDelta(org.erlide.engine.model.root.IErlElementDelta) IErlElementDelta(org.erlide.engine.model.root.IErlElementDelta) ErlElementDelta(org.erlide.engine.internal.model.root.ErlElementDelta) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 20 with IErlElement

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

the class ModelInternalUtils method getIncludeLibPath.

private String getIncludeLibPath(final IErlModule module) {
    String s = module.getName();
    String prevS = s;
    IErlElement e = module;
    for (; ; ) {
        final IParent p = e.getParent();
        if (p instanceof IErlProject) {
            break;
        }
        e = (IErlElement) p;
        prevS = s;
        s = e.getName() + "/" + s;
    }
    return prevS;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlProject(org.erlide.engine.model.root.IErlProject) IParent(org.erlide.engine.model.IParent)

Aggregations

IErlElement (org.erlide.engine.model.IErlElement)123 Test (org.junit.Test)36 IErlModule (org.erlide.engine.model.root.IErlModule)35 ErlModelException (org.erlide.engine.model.ErlModelException)28 IParent (org.erlide.engine.model.IParent)17 IFile (org.eclipse.core.resources.IFile)16 ArrayList (java.util.ArrayList)12 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)11 IResource (org.eclipse.core.resources.IResource)11 IErlProject (org.erlide.engine.model.root.IErlProject)10 IOpenable (org.erlide.engine.model.root.IOpenable)10 IProject (org.eclipse.core.resources.IProject)9 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)8 IErlModel (org.erlide.engine.model.root.IErlModel)8 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)8 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)7 IFolder (org.eclipse.core.resources.IFolder)7 CoreException (org.eclipse.core.runtime.CoreException)7 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)6 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)6