Search in sources :

Example 1 with IErlProject

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

the class ParserDB method run.

private void run(final IErlModel model, final Collection<SourcePathProvider> sourcePathProviders, final boolean includeTests) throws ErlModelException {
    // we include all projects in workspace - create one for OTP too
    int normal = 0;
    int test = 0;
    final Collection<IErlProject> projects = model.getErlangProjects();
    for (final IErlProject project : projects) {
        final Collection<IErlModule> modules = project.getModulesAndIncludes();
        for (final IErlModule module : modules) {
            if (isTest(module.getResource().getLocation().toPortableString())) {
                test++;
            } else {
                normal++;
            }
            handleModule(module);
        }
        if (includeTests) {
        // final TestCodeBuilder builder = new TestCodeBuilder();
        // try {
        // final Set<BuildResource> resources = builder
        // .getAffectedResources(
        // (IProject) project.getResource(),
        // new NullProgressMonitor(), false);
        // for (final BuildResource res : resources) {
        // if (res.getResource().isLinked()
        // || res.getResource().isDerived()) {
        // System.out.println("SKIP!!!! " + res.getResource());
        // continue;
        // }
        // test++;
        // final IErlModule module = ErlModelManager
        // .getInstance().getModel().findModule(
        // (IFile) res.getResource());
        // handleModule(module);
        // }
        // } catch (final CoreException e) {
        // ErlLogger.error(e);
        // }
        }
    }
    ParserDB.out.println("--- " + normal + " " + test);
    System.out.println("--- " + normal + " " + test);
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 2 with IErlProject

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

the class ParserDB method getTestSourcePaths.

public List<String> getTestSourcePaths(final Collection<SourcePathProvider> sourcePathProviders, final Collection<IErlProject> projects) {
    final List<String> spaths = Lists.newArrayList();
    for (final IErlProject project : projects) {
        final Set<IPath> paths = Sets.newHashSet();
        for (final SourcePathProvider provider : sourcePathProviders) {
            final IProject resource = (IProject) project.getResource();
            paths.addAll(provider.getSourcePathsForModel(resource));
        }
        for (final IPath path : paths) {
            spaths.add(path.toPortableString());
        }
    }
    Collections.sort(spaths);
    return spaths;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) SourcePathProvider(org.erlide.engine.model.root.SourcePathProvider) IProject(org.eclipse.core.resources.IProject)

Example 3 with IErlProject

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

the class SearchCoreUtil method getWorkspaceScope.

public static ErlSearchScope getWorkspaceScope(final boolean addExternals, final boolean addOtp) throws ErlModelException {
    final ErlSearchScope result = new ErlSearchScope();
    final Collection<IErlProject> erlangProjects = ErlangEngine.getInstance().getModel().getErlangProjects();
    for (final IErlProject i : erlangProjects) {
        final Collection<IErlModule> modules = i.getModulesAndIncludes();
        for (final IErlModule j : modules) {
            result.addModule(j);
        }
    // addProjectEbin(i, result);
    }
    final Set<String> externalModulePaths = new HashSet<>();
    for (final IErlProject project : erlangProjects) {
        SearchCoreUtil.addExternalModules(project, result, externalModulePaths, addExternals, addOtp);
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) ErlSearchScope(org.erlide.engine.services.search.ErlSearchScope) HashSet(java.util.HashSet)

Example 4 with IErlProject

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

the class DialyzerUtils method collectModulesFromResource.

public static Set<IErlModule> collectModulesFromResource(final IErlElementLocator model, final IResource resource) throws ErlModelException {
    final Set<IErlModule> result = Sets.newHashSet();
    final IErlElement element = model.findElement(resource, true);
    if (element == null) {
        return result;
    }
    if (element instanceof IErlFolder) {
        final IErlFolder folder = (IErlFolder) element;
        folder.open(null);
        result.addAll(folder.getModules());
    } else if (element instanceof IErlModule) {
        final IErlModule module = (IErlModule) element;
        result.add(module);
    } else if (element instanceof IErlProject) {
        final IErlProject project = (IErlProject) element;
        project.open(null);
        result.addAll(project.getModules());
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) IErlFolder(org.erlide.engine.model.root.IErlFolder)

Example 5 with IErlProject

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

the class ErlangEclipseBuilder method build.

@Override
public IProject[] build(final int kind, final Map<String, String> args, final IProgressMonitor monitor) throws CoreException {
    final IProject project = getProject();
    if (project == null || !project.isAccessible()) {
        return null;
    }
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
    final ProjectConfigType config = erlProject.getConfigType();
    final BuilderTool tool = erlProject.getBuilderProperties().getBuilderTool();
    if (!validateBuildConfiguration(erlProject)) {
        ErlLogger.warn("Builder tool and config mismatch: " + tool + " " + config);
        monitor.setCanceled(true);
    }
    final ErlangBuilder builder = ErlangBuilderFactory.get(tool);
    if (builder != null) {
        final BuildNotifier notifier = new BuildNotifier(monitor, project);
        if (builder instanceof InternalBuilder) {
            // temporary hack; rebar builder will not need this
            ((InternalBuilder) builder).setDelta(getDelta(project));
        }
        builder.build(ErlangBuilder.BuildKind.get(kind), erlProject, notifier);
    }
    return null;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) BuilderTool(org.erlide.engine.model.builder.BuilderTool) IProject(org.eclipse.core.resources.IProject) ProjectConfigType(org.erlide.engine.model.root.ProjectConfigType)

Aggregations

IErlProject (org.erlide.engine.model.root.IErlProject)123 IErlModule (org.erlide.engine.model.root.IErlModule)57 Test (org.junit.Test)47 IPath (org.eclipse.core.runtime.IPath)30 IProject (org.eclipse.core.resources.IProject)29 ErlProject (org.erlide.engine.internal.model.root.ErlProject)25 File (java.io.File)19 Path (org.eclipse.core.runtime.Path)16 CoreException (org.eclipse.core.runtime.CoreException)13 ErlModelException (org.erlide.engine.model.ErlModelException)13 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)13 IErlModel (org.erlide.engine.model.root.IErlModel)13 ArrayList (java.util.ArrayList)11 IErlElement (org.erlide.engine.model.IErlElement)10 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 HashSet (java.util.HashSet)7 IProjectDescription (org.eclipse.core.resources.IProjectDescription)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)6 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)6