KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > compiler > CompilationParticipant


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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  * mkaufman@bea.com - initial API as ICompilationParticipant
10  * IBM - changed from interface ICompilationParticipant to abstract class CompilationParticipant
11  * IBM - rewrote spec
12  *
13  *******************************************************************************/

14
15 package org.eclipse.jdt.core.compiler;
16
17 import org.eclipse.jdt.core.IJavaProject;
18
19 /**
20  * A compilation participant is notified of events occuring during the compilation process.
21  * The compilation process not only involves generating .class files (i.e. building), it also involves
22  * cleaning the output directory, reconciling a working copy, etc.
23  * So the notified events are the result of a build action, a clean action, a reconcile operation
24  * (for a working copy), etc.
25  * <p>
26  * Code that participates in the build should in general be implemented with a separate Builder,
27  * rather than a CompilationParticipant. It is only necessary to use a CompilationParticipant if
28  * the build step needs to interact with the Java build, for instance by creating additional
29  * Java source files that must themselves in turn be compiled.
30  * <p>
31  * Clients wishing to participate in the compilation process must suclass this class, and implement
32  * {@link #isActive(IJavaProject)}, {@link #aboutToBuild(IJavaProject)},
33  * {@link #reconcile(ReconcileContext)}, etc.
34 * </p><p>
35  * This class is intended to be subclassed by clients.
36  * </p>
37  * @since 3.2
38  */

39 public abstract class CompilationParticipant {
40
41 public static int READY_FOR_BUILD = 1;
42 public static int NEEDS_FULL_BUILD = 2;
43
44 /**
45  * Notifies this participant that a build is about to start and provides it the opportunity to
46  * create missing source folders for generated source files. Additional source folders
47  * should be marked as optional so the project can be built when the folders do not exist.
48  * Only sent to participants interested in the project.
49  * <p>
50  * Default is to return <code>READY_FOR_BUILD</code>.
51  * </p>
52  * @param project the project about to build
53  * @return READY_FOR_BUILD or NEEDS_FULL_BUILD
54  */

55 public int aboutToBuild(IJavaProject project) {
56     return READY_FOR_BUILD;
57 }
58
59 /**
60  * Notifies this participant that a compile operation is about to start and provides it the opportunity to
61  * generate source files based on the source files about to be compiled.
62  * When isBatchBuild is true, then files contains all source files in the project.
63  * Only sent to participants interested in the current build project.
64  *
65  * @param files is an array of BuildContext
66  * @param isBatch identifies when the build is a batch build
67   */

68 public void buildStarting(BuildContext[] files, boolean isBatch) {
69     // do nothing by default
70
}
71
72 /**
73  * Notifies this participant that a clean is about to start and provides it the opportunity to
74  * delete generated source files.
75  * Only sent to participants interested in the project.
76  * @param project the project about to be cleaned
77  */

78 public void cleanStarting(IJavaProject project) {
79     // do nothing by default
80
}
81
82 /**
83  * Returns whether this participant is active for a given project.
84  * <p>
85  * Default is to return <code>false</code>.
86  * </p><p>
87  * For efficiency, participants that are not interested in the
88  * given project should return <code>false</code> for that project.
89  * </p>
90  * @param project the project to participate in
91  * @return whether this participant is active for a given project
92  */

93 public boolean isActive(IJavaProject project) {
94     return false;
95 }
96
97 /**
98  * Returns whether this participant is interested in only Annotations.
99  * <p>
100  * Default is to return <code>false</code>.
101  * </p>
102  * @return whether this participant is interested in only Annotations.
103  */

104 public boolean isAnnotationProcessor() {
105     return false;
106 }
107
108 /**
109  * Notifies this participant that a compile operation has found source files using Annotations.
110  * Only sent to participants interested in the current build project that answer true to isAnnotationProcessor().
111  * Each BuildContext was informed whether its source file currently hasAnnotations().
112  *
113  * @param files is an array of BuildContext
114   */

115 public void processAnnotations(BuildContext[] files) {
116     // do nothing by default
117
}
118
119 /**
120  * Notifies this participant that a reconcile operation is happening. The participant can act on this reconcile
121  * operation by using the given context. Other participant can then see the result of this participation
122  * on this context.
123  * <p>
124  * Note that a participant should not modify the buffer of the working copy that is being reconciled.
125  * </p><p>
126  * Default is to do nothing.
127  * </p>
128  * @param context the reconcile context to act on
129   */

130 public void reconcile(ReconcileContext context) {
131     // do nothing by default
132
}
133
134 }
135
Popular Tags