1 /*******************************************************************************
2  * Copyright (c) 2008 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.core.compiler;
12 
13 import org.eclipse.jdt.core.compiler.batch.BatchCompiler;
14 
15 /**
16  * A compilation progress is used by the {@link BatchCompiler} to report progress during compilation.
17  * It is also used to request cancellation of the compilation.
18  * Clients of the {@link BatchCompiler} should subclass this class, instantiate the subclass and pass this instance to
19  * {@link BatchCompiler#compile(String, java.io.PrintWriter, java.io.PrintWriter, CompilationProgress)}.
20  * <p>
21  * This class is intended to be instantiated and subclassed by clients.
22  * </p>
23  *
24  * @since 3.4
25  */
26 
27 public abstract class CompilationProgress {
28 
29 	/**
30 	 * Notifies that the compilation is beginning. This is called exactly once per batch compilation.
31 	 * An estimated amount of remaining work is given. This amount will change as the compilation
32 	 * progresses. The new estimated amount of remaining work is reported using {@link #worked(int, int)}.
33 	 * <p>
34 	 * Clients should not call this method.
35 	 * </p>
36 	 *
37 	 * @param remainingWork the estimated amount of remaining work.
38 	 */
begin(int remainingWork)39 	public abstract void begin(int remainingWork);
40 
41 	/**
42 	 * Notifies that the work is done; that is, either the compilation is completed
43 	 * or a cancellation was requested. This is called exactly once per batch compilation.
44 	 * <p>
45 	 * Clients should not call this method.
46 	 * </p>
47 	 */
done()48 	public abstract void done();
49 
50 	/**
51 	 * Returns whether cancellation of the compilation has been requested.
52 	 *
53 	 * @return <code>true</code> if cancellation has been requested,
54 	 *    and <code>false</code> otherwise
55 	 */
isCanceled()56 	public abstract boolean isCanceled();
57 
58 	/**
59 	 * Reports the name (or description) of the current task.
60 	 * <p>
61 	 * Clients should not call this method.
62 	 * </p>
63 	 *
64 	 * @param name the name (or description) of the current task
65 	 */
setTaskName(String name)66 	public abstract void setTaskName(String name);
67 
68 
69 	/**
70 	 * Notifies that a given amount of work of the compilation
71 	 * has been completed. Note that this amount represents an
72 	 * installment, as opposed to a cumulative amount of work done
73 	 * to date.
74 	 * Also notifies an estimated amount of remaining work. Note that this
75 	 * amount of remaining work  may be greater than the previous estimated
76 	 * amount as new compilation units are injected in the compile loop.
77 	 * <p>
78 	 * Clients should not call this method.
79 	 * </p>
80 	 *
81 	 * @param workIncrement a non-negative amount of work just completed
82 	 * @param remainingWork  a non-negative amount of estimated remaining work
83 	 */
worked(int workIncrement, int remainingWork)84 	public abstract void worked(int workIncrement, int remainingWork);
85 
86 
87 }
88