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

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

Introduction

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

Prototype

public void cleanStarting(IJavaProject project) 

Source Link

Document

Notifies this participant that a clean is about to start and provides it the opportunity to delete generated source files.

Usage

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

License:Open Source License

protected void clean(IProgressMonitor monitor) throws CoreException {
    // implemented as part of bug 101481
    IProject project = getProject();//w  w  w  .  j  a  va 2s .c  o m
    // Remove the compiler instance associated with this project
    // from the factory
    AspectJPlugin.getDefault().getCompilerFactory().removeCompilerForProject(project);
    AJProjectModelFactory.getInstance().removeModelForProject(project);

    // handle participants
    final IJavaProject javaProject = JavaCore.create(project);
    CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants
            .getCompilationParticipants(javaProject);
    if (participants != null) {
        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.cleanStarting(javaProject);
                }
            });
        }
    }

    removeProblemsAndTasksFor(project);
    // clean the output folders and do a refresh if not
    // automatically building (so that output dir reflects the
    // changes)
    cleanOutputFolders(JavaCore.create(project),
            !AspectJPlugin.getWorkspace().getDescription().isAutoBuilding());

    postCleanCallListeners();
}