Search in sources :

Example 1 with IErlExternalRoot

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

the class ErlangExternalsContentProvider method hasChildren.

@Override
public boolean hasChildren(final Object element0) {
    Object element = element0;
    if (element instanceof IProject) {
        final IProject project = (IProject) element;
        if (project.isOpen()) {
            element = ErlangEngine.getInstance().getModel().findProject(project);
        }
    }
    if (element instanceof IErlModule) {
        return erlangFileContentProvider.hasChildren(element);
    }
    if (element instanceof IParent) {
        if (element instanceof IErlExternalRoot || element instanceof IErlProject || element instanceof IErlModel) {
            // we know these have children
            return true;
        }
        final Stopwatch clock = Stopwatch.createStarted();
        if (element instanceof IOpenable) {
            final IOpenable openable = (IOpenable) element;
            try {
                openable.open(null);
            } catch (final ErlModelException e) {
            }
        }
        final IParent parent = (IParent) element;
        final boolean result = parent.hasChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER, ErlElementKind.MODULE);
        if (clock.elapsed(TimeUnit.MILLISECONDS) > 100) {
            ErlLogger.debug("TIME open " + element.getClass() + " " + element + "  " + clock.elapsed(TimeUnit.MILLISECONDS) + " ms");
        }
        return result;
    }
    return false;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IOpenable(org.erlide.engine.model.root.IOpenable) IErlModel(org.erlide.engine.model.root.IErlModel) IParent(org.erlide.engine.model.IParent) ErlModelException(org.erlide.engine.model.ErlModelException) IErlExternalRoot(org.erlide.engine.model.root.IErlExternalRoot) IErlModule(org.erlide.engine.model.root.IErlModule) Stopwatch(com.google.common.base.Stopwatch) IProject(org.eclipse.core.resources.IProject)

Example 2 with IErlExternalRoot

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

the class ErlProject method addExternals.

private void addExternals(final List<IErlElement> children) {
    final ErlangProjectProperties myProperties = getProperties();
    final String externalIncludes = myProperties.getExternalIncludes();
    final String externalModules = myProperties.getExternalModules();
    final Collection<IPath> includeDirs = myProperties.getIncludeDirs();
    final List<String> projectIncludes = Lists.newArrayList();
    for (final IPath path : new PathResolver().resolvePaths(includeDirs)) {
        if (path.isAbsolute() && !fProject.getLocation().isPrefixOf(path)) {
            final Collection<String> includes = ErlangEngine.getInstance().getOpenService().getIncludesInDir(path.toPortableString());
            if (includes != null) {
                for (final String include : includes) {
                    projectIncludes.add(path.append(include).toPortableString());
                }
            }
        }
    }
    if (!externalIncludes.isEmpty() || !externalModules.isEmpty() || !projectIncludes.isEmpty()) {
        final IErlExternalRoot external = new ErlExternalReferenceEntryList(this, "Externals", externalIncludes, projectIncludes, externalModules);
        children.add(external);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) IErlExternalRoot(org.erlide.engine.model.root.IErlExternalRoot) PathResolver(org.erlide.engine.model.root.PathResolver)

Aggregations

IErlExternalRoot (org.erlide.engine.model.root.IErlExternalRoot)2 Stopwatch (com.google.common.base.Stopwatch)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 ErlModelException (org.erlide.engine.model.ErlModelException)1 IParent (org.erlide.engine.model.IParent)1 ErlangProjectProperties (org.erlide.engine.model.root.ErlangProjectProperties)1 IErlModel (org.erlide.engine.model.root.IErlModel)1 IErlModule (org.erlide.engine.model.root.IErlModule)1 IErlProject (org.erlide.engine.model.root.IErlProject)1 IOpenable (org.erlide.engine.model.root.IOpenable)1 PathResolver (org.erlide.engine.model.root.PathResolver)1