Search in sources :

Example 21 with IParent

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

the class ModelFindUtil method getLocalIncludes.

private Collection<IErlModule> getLocalIncludes(final IErlModule module) throws ErlModelException {
    final List<IErlModule> result = Lists.newArrayList();
    final IParent parent = module.getParent();
    for (final IErlElement child : parent.getChildrenOfKind(ErlElementKind.MODULE)) {
        if (child instanceof IErlModule && SourceKind.nameToModuleKind(child.getName()) == SourceKind.HRL) {
            result.add((IErlModule) child);
        }
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IParent(org.erlide.engine.model.IParent) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 22 with IParent

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

the class ModelInternalUtils method getModuleFromExternalModulePath.

@Override
public IErlModule getModuleFromExternalModulePath(final IErlModel model, final String modulePath) throws ErlModelException {
    System.out.println(">> modulePath=" + modulePath);
    final List<String> path = Lists.newArrayList(Splitter.on(ModelInternalUtils.DELIMITER).split(modulePath));
    model.open(null);
    final IErlElement childNamed = model.getChildNamed(path.get(0));
    if (childNamed instanceof IParent) {
        IParent parent = (IParent) childNamed;
        final int n = path.size() - 1;
        for (int i = 1; ; i++) {
            if (parent == null) {
                break;
            }
            if (parent instanceof IOpenable) {
                final IOpenable openable = (IOpenable) parent;
                openable.open(null);
            }
            if (i == n) {
                break;
            }
            parent = getElementWithExternalName(parent, path.get(i));
        }
        if (parent != null) {
            final IErlElement child = parent.getChildNamed(path.get(n));
            if (child instanceof IErlModule) {
                return (IErlModule) child;
            }
        }
    }
    return null;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable) IParent(org.erlide.engine.model.IParent) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 23 with IParent

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

the class SourceRefElement method getOpenableParent.

/**
 * Return the first instance of IOpenable in the hierarchy of this type
 * (going up the hierarchy from this type);
 */
@Override
public IOpenable getOpenableParent() {
    IParent parent = getParent();
    while (parent != null) {
        if (parent instanceof IOpenable) {
            return (IOpenable) parent;
        }
        if (parent instanceof IErlElement) {
            final IErlElement parentElement = (IErlElement) parent;
            parent = parentElement.getParent();
        } else {
            break;
        }
    }
    return null;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable) IParent(org.erlide.engine.model.IParent)

Example 24 with IParent

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

the class ErlElement method toStringAncestors.

/**
 * Debugging purposes
 */
protected void toStringAncestors(final StringBuilder buffer) {
    final IParent parent = getParent();
    if (parent != null) {
        if (parent instanceof ErlElement) {
            final ErlElement parentElement = (ErlElement) parent;
            // $NON-NLS-1$
            buffer.append("[> ");
            parentElement.toStringInfo(0, buffer, ErlElement.NO_INFO);
            parentElement.toStringAncestors(buffer);
        }
        // $NON-NLS-1$
        buffer.append("] ");
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IParent(org.erlide.engine.model.IParent)

Aggregations

IParent (org.erlide.engine.model.IParent)24 IErlElement (org.erlide.engine.model.IErlElement)18 IErlModule (org.erlide.engine.model.root.IErlModule)10 IOpenable (org.erlide.engine.model.root.IOpenable)8 IResource (org.eclipse.core.resources.IResource)5 ErlModelException (org.erlide.engine.model.ErlModelException)5 IErlProject (org.erlide.engine.model.root.IErlProject)3 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 HashSet (java.util.HashSet)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 IErlExternal (org.erlide.engine.model.root.IErlExternal)2 IErlFolder (org.erlide.engine.model.root.IErlFolder)2 ErlSearchScope (org.erlide.engine.services.search.ErlSearchScope)2 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 Stopwatch (com.google.common.base.Stopwatch)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 IContainer (org.eclipse.core.resources.IContainer)1