Search in sources :

Example 1 with DialyzerBuilder

use of org.erlide.dialyzer.internal.builder.DialyzerBuilder in project erlide_eclipse by erlang.

the class InternalBuilder method build.

@Override
public IProject[] build(final BuildKind kind, final IErlProject erlProject, final BuildNotifier notifier) throws CoreException {
    final long time = System.currentTimeMillis();
    final IProject project = erlProject.getWorkspaceProject();
    if (project == null || !project.isAccessible()) {
        return null;
    }
    final DialyzerBuilder dialyzerBuilder = new DialyzerBuilder(project);
    if (BuilderHelper.isDebugging()) {
        ErlLogger.trace("build", "Start " + project.getName() + ": " + kind);
    }
    try {
        initializeBuilder(notifier);
        // TODO validate source and include directories
        final ErlangProjectProperties properties = erlProject.getProperties();
        final IPath out = properties.getOutputDir();
        final IResource outr = project.findMember(out);
        if (outr != null) {
            try {
                outr.setDerived(true, null);
                outr.refreshLocal(IResource.DEPTH_ZERO, null);
            } catch (final CoreException e) {
            // ignore it
            }
        }
        if (delta != null && delta.getAffectedChildren().length != 0) {
            handleAppFile(project, project.getLocation().toPortableString() + "/" + out, properties.getSourceDirs());
        }
        handleErlangFiles(erlProject, project, kind, delta, notifier);
        dialyzerBuilder.build(notifier);
        if (project.findMember("rebar.config") != null) {
            final IResource buildr = project.findMember("_build");
            if (buildr != null) {
                try {
                    buildr.setDerived(true, null);
                    buildr.refreshLocal(IResource.DEPTH_ZERO, null);
                } catch (final CoreException e) {
                // ignore it
                }
            }
        }
    } catch (final OperationCanceledException e) {
        if (BuilderHelper.isDebugging()) {
            ErlLogger.debug("Build of " + project.getName() + " was canceled.");
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
        final String msg = NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage(), e.getClass().getName());
        MarkerUtils.createProblemMarker(project, null, msg, 0, IMarker.SEVERITY_ERROR);
    } finally {
        cleanup(notifier);
        if (BuilderHelper.isDebugging()) {
            ErlLogger.trace("build", " Done " + project.getName() + " took " + Long.toString(System.currentTimeMillis() - time));
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) DialyzerBuilder(org.erlide.dialyzer.internal.builder.DialyzerBuilder) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) 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 2 with DialyzerBuilder

use of org.erlide.dialyzer.internal.builder.DialyzerBuilder in project erlide_eclipse by erlang.

the class InternalBuilder method clean.

@Override
public void clean(final IErlProject erlProject, final BuildNotifier notifier) {
    final IProject currentProject = erlProject.getWorkspaceProject();
    if (currentProject == null || !currentProject.isAccessible()) {
        return;
    }
    final DialyzerBuilder dialyzerBuilder = new DialyzerBuilder(currentProject);
    if (BuilderHelper.isDebugging()) {
        ErlLogger.trace("build", // $NON-NLS-1$
        "Cleaning " + currentProject.getName() + " @ " + new Date(System.currentTimeMillis()));
    }
    try {
        initializeBuilder(notifier);
        MarkerUtils.removeProblemMarkersFor(currentProject);
        final IFolder bf = currentProject.getFolder(erlProject.getProperties().getOutputDir());
        if (bf.exists()) {
            cleanupOutput(bf, notifier);
        }
        dialyzerBuilder.clean(notifier);
    } catch (final Exception e) {
        ErlLogger.error(e);
        final String msg = NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage(), e.getClass().getName());
        MarkerUtils.createProblemMarker(currentProject, null, msg, 0, IMarker.SEVERITY_ERROR);
    } finally {
        cleanup(notifier);
        if (BuilderHelper.isDebugging()) {
            ErlLogger.debug(// $NON-NLS-1$
            "Finished cleaning " + currentProject.getName() + " @ " + new Date(System.currentTimeMillis()));
        }
    }
}
Also used : DialyzerBuilder(org.erlide.dialyzer.internal.builder.DialyzerBuilder) IProject(org.eclipse.core.resources.IProject) Date(java.util.Date) CoreException(org.eclipse.core.runtime.CoreException) ErlModelException(org.erlide.engine.model.ErlModelException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) BackendException(org.erlide.backend.api.BackendException) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IProject (org.eclipse.core.resources.IProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 BackendException (org.erlide.backend.api.BackendException)2 DialyzerBuilder (org.erlide.dialyzer.internal.builder.DialyzerBuilder)2 ErlModelException (org.erlide.engine.model.ErlModelException)2 Date (java.util.Date)1 IFolder (org.eclipse.core.resources.IFolder)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 ErlangProjectProperties (org.erlide.engine.model.root.ErlangProjectProperties)1