Search in sources :

Example 76 with IErlElement

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

the class ErlModule method getImports.

@Override
public Collection<IErlImport> getImports() {
    final List<IErlImport> result = new ArrayList<>();
    synchronized (getModelLock()) {
        for (final IErlElement e : internalGetChildren()) {
            if (e instanceof IErlImport) {
                final IErlImport ei = (IErlImport) e;
                result.add(ei);
            }
        }
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ArrayList(java.util.ArrayList) IErlImport(org.erlide.engine.model.erlang.IErlImport)

Example 77 with IErlElement

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

the class ErlProject method addOtpExternals.

private void addOtpExternals(final List<IErlElement> children) {
    final String name = "OTP " + getRuntimeVersion().toString();
    IErlElement external = getChildNamed(name);
    if (external == null) {
        external = new ErlOtpExternalReferenceEntryList(this, name);
    }
    children.add(external);
}
Also used : IErlElement(org.erlide.engine.model.IErlElement)

Example 78 with IErlElement

use of org.erlide.engine.model.IErlElement 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 79 with IErlElement

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

the class ErlProject method getExternalIncludes.

@Override
public Collection<IErlModule> getExternalIncludes() throws ErlModelException {
    final List<IErlModule> result = Lists.newArrayList();
    accept(new IErlElementVisitor() {

        @Override
        public boolean visit(final IErlElement element) throws ErlModelException {
            final boolean isExternalOrProject = element.getKind() == ErlElementKind.EXTERNAL_ROOT || element.getKind() == ErlElementKind.EXTERNAL_APP || element.getKind() == ErlElementKind.EXTERNAL_FOLDER || element.getKind() == ErlElementKind.PROJECT;
            if (element instanceof IErlModule) {
                final IErlModule module = (IErlModule) element;
                if (module.getSourceKind() == SourceKind.HRL && (module.getAncestorOfKind(ErlElementKind.PROJECT) == ErlProject.this || element.getKind() == ErlElementKind.EXTERNAL_APP || element.getKind() == ErlElementKind.EXTERNAL_FOLDER)) {
                    result.add(module);
                }
                return false;
            } else if (isExternalOrProject && element instanceof IOpenable) {
                final IOpenable openable = (IOpenable) element;
                openable.open(null);
            }
            return isExternalOrProject;
        }
    }, EnumSet.noneOf(AcceptFlags.class), ErlElementKind.MODULE);
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable) ErlModelException(org.erlide.engine.model.ErlModelException) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementVisitor(org.erlide.engine.model.IErlElementVisitor)

Example 80 with IErlElement

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

the class Openable method close.

@Override
public void close() throws ErlModelException {
    for (final IErlElement child : getChildren()) {
        if (child instanceof IOpenable) {
            final IOpenable openable = (IOpenable) child;
            if (openable.isOpen()) {
                openable.close();
            }
        }
    }
    internalGetChildren().clear();
    setStructureKnown(false);
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable)

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