Example usage for org.eclipse.jdt.internal.core.builder BuildNotifier BuildNotifier

List of usage examples for org.eclipse.jdt.internal.core.builder BuildNotifier BuildNotifier

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.builder BuildNotifier BuildNotifier.

Prototype

public BuildNotifier(IProgressMonitor monitor, IProject project) 

Source Link

Usage

From source file:org.jboss.tools.arquillian.core.internal.compiler.ArquillianCompilationParticipant.java

License:Open Source License

@Override
public void buildFinished(IJavaProject project) {
    if (ArquillianCoreActivator.getDefault() == null) {
        return;/*from w  w  w  . ja  v  a  2 s .  com*/
    }
    try {
        project.getProject().deleteMarkers(ArquillianConstants.MARKER_CLASS_ID, false,
                IResource.DEPTH_INFINITE);
        project.getProject().deleteMarkers(ArquillianConstants.MARKER_RESOURCE_ID, false,
                IResource.DEPTH_INFINITE);
    } catch (CoreException e) {
        ArquillianCoreActivator.log(e);
    }
    if (!ArquillianUtility.isValidatorEnabled(project.getProject())) {
        return;
    }
    try {
        IMarker[] markers = project.getProject().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        for (IMarker marker : markers) {
            Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
            if (severity != null && severity.intValue() == IMarker.SEVERITY_ERROR
                    && JavaBuilder.SOURCE_ID.equals(marker.getAttribute(IMarker.SOURCE_ID))) {
                return;
            }
        }
    } catch (CoreException e1) {
        // ignore
    }
    List<SourceFile> sourceFiles = new ArrayList(33);
    this.problemSourceFiles = new ArrayList(3);
    this.notifier = new BuildNotifier(new NullProgressMonitor(), project.getProject());
    this.notifier.begin();
    compiler = newCompiler(project);
    this.notifier.updateProgressDelta(0.05f);

    this.notifier.subTask(Messages.build_analyzingSources);
    sourceLocations = nameEnvironment.sourceLocations;
    try {
        addAllSourceFiles(sourceFiles, project);
    } catch (CoreException e) {
        ArquillianCoreActivator.log(e);
    }
    this.notifier.updateProgressDelta(0.10f);
    if (sourceFiles.size() <= 0) {
        return;
    }
    Iterator<SourceFile> iterator = sourceFiles.iterator();
    while (iterator.hasNext()) {
        SourceFile sourceFile = iterator.next();

        boolean remove = false;
        String preference = ArquillianUtility.getPreference(ArquillianConstants.MISSING_DEPLOYMENT_METHOD,
                project.getProject());

        if (!JavaCore.IGNORE.equals(preference)
                && !ArquillianSearchEngine.hasDeploymentMethod(sourceFile, project)) {
            try {
                Integer severity = ArquillianUtility.getSeverity(preference);
                storeProblem(sourceFile,
                        "Arquillian test requires at least one method annotated with @Deployment", severity);
            } catch (CoreException e) {
                ArquillianCoreActivator.log(e);
            }
            remove = true;
        }
        preference = ArquillianUtility.getPreference(ArquillianConstants.MISSING_TEST_METHOD,
                project.getProject());
        if (!JavaCore.IGNORE.equals(preference) && !ArquillianSearchEngine.hasTestMethod(sourceFile, project)) {
            try {
                Integer severity = ArquillianUtility.getSeverity(preference);
                storeProblem(sourceFile, "Arquillian test requires at least one method annotated with @Test",
                        severity);
            } catch (CoreException e) {
                ArquillianCoreActivator.log(e);
            }
            remove = true;
        }
        if (remove) {
            iterator.remove();
        }

    }
    for (SourceFile sourceFile : sourceFiles) {
        if (nameEnvironment.setEnvironment(sourceFile, project)) {
            compile(new SourceFile[] { sourceFile });
        }
    }

}