Search in sources :

Example 6 with IErlProject

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

the class InternalBuilder method fillAppFileDetails.

private void fillAppFileDetails(final IProject project, final String appSrc, final String destPath, final Collection<String> modules) {
    try {
        final IErlProject eproject = ErlangEngine.getInstance().getModel().findProject(project);
        if (eproject == null) {
            return;
        }
        final IBackend backend = BackendCore.getBackendManager().getBuildBackend(eproject);
        backend.getOtpRpc().call("erlide_builder", "compile_app_src", "ssla", appSrc, destPath, modules);
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IBackend(org.erlide.backend.api.IBackend) CoreException(org.eclipse.core.runtime.CoreException) ErlModelException(org.erlide.engine.model.ErlModelException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) BackendException(org.erlide.backend.api.BackendException)

Example 7 with IErlProject

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

the class BuilderHelper method getIncludeDirs.

public Collection<IPath> getIncludeDirs(final IProject project) {
    final Collection<IPath> includeDirs = new ArrayList<>();
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
    if (erlProject == null) {
        return includeDirs;
    }
    final Collection<IPath> projectIncludeDirs = erlProject.getProperties().getIncludeDirs();
    final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
    for (final IPath inc : projectIncludeDirs) {
        final IPath incPath = URIUtil.toPath(pvm.resolveURI(URIUtil.toURI(inc)));
        if (incPath.isAbsolute()) {
            includeDirs.add(incPath);
        } else {
            final IFolder folder = project.getFolder(incPath);
            if (folder != null && folder.exists()) {
                final IPath location = folder.getLocation();
                if (location != null) {
                    includeDirs.add(location);
                } else {
                    ErlLogger.warn("No location for %s", folder);
                }
            } else {
                if (!BuilderHelper.reportedMissingFolders.contains(folder)) {
                    ErlLogger.warn("Inexistent location for %s", folder);
                }
                BuilderHelper.reportedMissingFolders.add(folder);
            }
        }
    }
    return includeDirs;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) IPathVariableManager(org.eclipse.core.resources.IPathVariableManager) ArrayList(java.util.ArrayList) IFolder(org.eclipse.core.resources.IFolder)

Example 8 with IErlProject

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

the class BuilderHelper method loadModule.

public static void loadModule(@NonNull final IProject project, final String module) {
    try {
        final IBackendManager backendManager = BackendCore.getBackendManager();
        for (final IBackend b : backendManager.getExecutionBackends(project)) {
            ErlLogger.debug(":: loading %s in %s", module, b.getName());
            final IErlProject erlProject = ErlangEngine.getInstance().getModel().findProject(project);
            final IPath path = project.getLocation().append(erlProject.getProperties().getOutputDir()).append(module + ".beam");
            boolean ok = false;
            final OtpErlangBinary bin = BeamUtil.getBeamBinary(module, path);
            if (bin != null) {
                ok = BeamLoader.loadBeam(b.getOtpRpc(), module, bin);
            }
            if (!ok) {
                ErlLogger.error("Could not load %s", module);
            }
            backendManager.moduleLoaded(b, project, module);
        }
    } catch (final Exception e) {
        ErlLogger.debug(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IBackendManager(org.erlide.backend.api.IBackendManager) IPath(org.eclipse.core.runtime.IPath) IBackend(org.erlide.backend.api.IBackend) OtpErlangBinary(com.ericsson.otp.erlang.OtpErlangBinary) CoreException(org.eclipse.core.runtime.CoreException) ErlModelException(org.erlide.engine.model.ErlModelException) RpcException(org.erlide.runtime.rpc.RpcException)

Example 9 with IErlProject

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

the class DialyzerBuilder method build.

public void build(final BuildNotifier notifier) throws CoreException {
    if (project == null) {
        return;
    }
    DialyzerPreferences prefs = null;
    prefs = DialyzerPreferences.get(project);
    if (prefs == null || !prefs.getDialyzeOnCompile()) {
        return;
    }
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    final Set<IErlModule> modules = DialyzerUtils.collectModulesFromResource(model, project);
    final Set<IErlProject> projects = Sets.newHashSet();
    projects.add(model.findProject(project));
    DialyzerMarkerUtils.removeDialyzerMarkersFor(project);
    if (!modules.isEmpty()) {
        try {
            final IErlProject eproject = model.findProject(project);
            if (eproject == null) {
                return;
            }
            final IBackend backend = BackendCore.getBackendManager().getBuildBackend(eproject);
            DialyzerUtils.doDialyze(notifier.monitor, modules, projects, backend);
        } catch (final InvocationTargetException e) {
            ErlLogger.error(e);
        } catch (final DialyzerErrorException e) {
            ErlLogger.error(e);
            final String msg = NLS.bind(BuilderMessages.build_dialyzerProblem, e.getLocalizedMessage());
            DialyzerMarkerUtils.addProblemMarker(project, null, null, msg, 0, IMarker.SEVERITY_ERROR);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IBackend(org.erlide.backend.api.IBackend) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) DialyzerPreferences(org.erlide.dialyzer.builder.DialyzerPreferences) InvocationTargetException(java.lang.reflect.InvocationTargetException) DialyzerErrorException(org.erlide.dialyzer.builder.DialyzerUtils.DialyzerErrorException)

Example 10 with IErlProject

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

the class EdocExportWizard method performFinish.

@Override
public boolean performFinish() {
    if (!validateFinish()) {
        return false;
    }
    final Collection<IProject> projects = page.getSelectedResources();
    final Map<String, OtpErlangObject> options = page.getOptions();
    for (final IProject project : projects) {
        if (!project.isAccessible()) {
            ErlLogger.debug("EDOC: " + project.getName() + " is not accessible, skipping.");
            continue;
        }
        ErlLogger.debug("EDOC: " + project.getName());
        try {
            final IFolder dest = project.getFolder(page.getDestination());
            if (!dest.exists()) {
                dest.create(true, true, null);
            }
            options.put("dir", new OtpErlangString(dest.getLocation().toString()));
            final List<String> files = new ArrayList<>();
            final IErlProject erlProject = ErlangEngine.getInstance().getModel().findProject(project);
            for (final IPath dir : erlProject.getProperties().getSourceDirs()) {
                final IFolder folder = project.getFolder(dir);
                if (folder.isAccessible()) {
                    folder.accept(new IResourceVisitor() {

                        @Override
                        public boolean visit(final IResource resource) throws CoreException {
                            if ("erl".equals(resource.getFileExtension())) {
                                if (resource.isAccessible()) {
                                    files.add(resource.getLocation().toString());
                                }
                            }
                            return true;
                        }
                    });
                }
            }
            try {
                ErlangEngine.getInstance().getEdocExportService().files(files, options);
            } catch (final Exception e) {
                ErlLogger.warn(e);
            }
        } catch (final CoreException e) {
            ErlLogger.warn(e);
        }
    }
    return true;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IResourceVisitor(org.eclipse.core.resources.IResourceVisitor) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

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