Package org.erlide.test_support.builder

Source Code of org.erlide.test_support.builder.TestProjectProperties

package org.erlide.test_support.builder;

import java.util.List;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.erlide.util.ErlLogger;

import com.google.common.collect.Lists;

public class TestProjectProperties {
    List<String> sources = Lists.newArrayList();

    @SuppressWarnings("unused")
    private List<String> findTestDirs(final IProject prj) {
        final List<String> result = Lists.newArrayList();
        try {
            prj.accept(new IResourceVisitor() {
                @Override
                public boolean visit(final IResource resource) throws CoreException {
                    if (resource.getName().matches(".*_SUITE.erl")) {
                        final IContainer dir = resource.getParent();
                        final IPath pdir = dir.getProjectRelativePath();
                        final String sdir = pdir.toString();
                        if (!sdir.contains("/garbage/") && !result.contains(sdir)) {
                            result.add(sdir);
                        }
                    }
                    return true;
                }
            });
        } catch (final CoreException e) {
            ErlLogger.debug(e);
        }
        return result;
    }

    public boolean isInPath(final IResource resource, final IProject project) {
        final IPath projectPath = project.getFullPath();
        final IPath exceptLastSegment = resource.getFullPath().removeLastSegments(1);
        for (final String element : sources) {
            final IPath sp = projectPath.append(new Path(element));
            if (sp.equals(exceptLastSegment)) {
                return true;
            }
        }

        return false;
    }
}
TOP

Related Classes of org.erlide.test_support.builder.TestProjectProperties

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.