Example usage for org.eclipse.jdt.core.compiler CompilationParticipant aboutToBuild

List of usage examples for org.eclipse.jdt.core.compiler CompilationParticipant aboutToBuild

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.compiler CompilationParticipant aboutToBuild.

Prototype

public int aboutToBuild(IJavaProject project) 

Source Link

Document

Notifies this participant that a build is about to start and provides it the opportunity to create missing source folders for generated source files.

Usage

From source file:org.eclipse.ajdt.core.builder.AJBuilder.java

License:Open Source License

/**
 * Calculates the {@link CompilationParticipant}s for project.  Returns null
 * if none are registered//w ww. ja  v a 2s . c  om
 * @param project project to calculate for
 * @return participants or null if none
 */
private CompilationParticipant[] calculateParticipants(IProject project) {
    final IJavaProject javaProject = JavaCore.create(project);
    CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants
            .getCompilationParticipants(javaProject);
    if (participants != null && participants.length > 0) {
        for (final CompilationParticipant participant : participants) {
            // from ReconcileWorkingCopyOperation
            SafeRunner.run(new ISafeRunnable() {
                public void handleException(Throwable exception) {
                    if (exception instanceof Error) {
                        throw (Error) exception; // errors are not supposed to be caught
                    } else if (exception instanceof OperationCanceledException)
                        throw (OperationCanceledException) exception;
                    else if (exception instanceof UnsupportedOperationException) {
                        // might want to disable participant as it tried to modify the buffer of the working copy being reconciled
                        Util.log(exception,
                                "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$
                    } else
                        Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$
                }

                public void run() throws Exception {
                    participant.aboutToBuild(javaProject);
                }
            });
        }
    } else {
        participants = null;
    }
    return participants;
}