1 /*******************************************************************************
2  * Copyright (c) 2006, 2018 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *     BEA - Patch for bug 172743
14  *******************************************************************************/
15 package org.eclipse.jdt.internal.compiler;
16 
17 import java.io.PrintWriter;
18 
19 import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
20 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
21 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
22 
23 public abstract class AbstractAnnotationProcessorManager {
24 	/**
25 	 * Configure the receiver using the given batch compiler and the given options.
26 	 * The parameter batchCompiler is expected to be an instance of the batch compiler. This method is
27 	 * only used for the batch mode. For the IDE mode, please see {@link #configureFromPlatform(Compiler, Object, Object, boolean)}.
28 	 *
29 	 * @param batchCompiler the given batch compiler object
30 	 * @param options the given options
31 	 */
configure(Object batchCompiler, String[] options)32 	public abstract void configure(Object batchCompiler, String[] options);
33 
34 	/**
35 	 * Configure the receiver using the given compiler, the given compilationUnitLocator and
36 	 * the given java project.
37 	 *
38 	 * @param compiler the given compiler
39 	 * @param compilationUnitLocator the given compilation unit locator
40 	 * @param javaProject the given java project
41 	 * @param isTestCode
42 	 */
configureFromPlatform(Compiler compiler, Object compilationUnitLocator, Object javaProject, boolean isTestCode)43 	public abstract void configureFromPlatform(Compiler compiler, Object compilationUnitLocator, Object javaProject, boolean isTestCode);
44 
45 	/**
46 	 * Set the print writer for the standard output.
47 	 *
48 	 * @param out the given print writer for output
49 	 */
setOut(PrintWriter out)50 	public abstract void setOut(PrintWriter out);
51 
52 	/**
53 	 * Set the print writer for the standard error.
54 	 *
55 	 * @param err the given print writer for error
56 	 */
setErr(PrintWriter err)57 	public abstract void setErr(PrintWriter err);
58 
59 	/**
60 	 * Return the new units created in the last round.
61 	 *
62 	 * @return the new units created in the last round
63 	 */
getNewUnits()64 	public abstract ICompilationUnit[] getNewUnits();
65 
66 	/**
67 	 * Return the new binary bindings created in the last round.
68 	 *
69 	 * @return the new binary bindings created in the last round
70 	 */
getNewClassFiles()71 	public abstract ReferenceBinding[] getNewClassFiles();
72 
73 	/**
74 	 * Returns the deleted units.
75 	 * @return the deleted units
76 	 */
getDeletedUnits()77 	public abstract ICompilationUnit[] getDeletedUnits();
78 
79 	/**
80 	 * Reinitialize the receiver
81 	 */
reset()82 	public abstract void reset();
83 
84 	/**
85 	 * Final cleanup after all rounds have completed.
86 	 */
cleanUp()87 	protected void cleanUp() {
88 		// default: do nothing, because reset() already did the common work
89 	}
90 
91 	/**
92 	 * Run a new annotation processing round on the given values.
93 	 *
94 	 * @param units the given source type
95 	 * @param referenceBindings the given binary types
96 	 * @param isLastRound flag to notify the last round
97 	 */
processAnnotations(CompilationUnitDeclaration[] units, ReferenceBinding[] referenceBindings, boolean isLastRound)98 	public abstract void processAnnotations(CompilationUnitDeclaration[] units, ReferenceBinding[] referenceBindings, boolean isLastRound);
99 
100 	/**
101 	 * Set the processors for annotation processing.
102 	 *
103 	 * @param processors the given processors
104 	 */
setProcessors(Object[] processors)105 	public abstract void setProcessors(Object[] processors);
106 }
107