KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > cs > drjava > model > compiler > CompilerModel


1 /*BEGIN_COPYRIGHT_BLOCK
2  *
3  * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
4  * or http://sourceforge.net/projects/drjava/
5  *
6  * DrJava Open Source License
7  *
8  * Copyright (C) 2001-2006 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
9  *
10  * Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13  * documentation files (the "Software"), to deal with the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15  * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16  *
17  * - Redistributions of source code must retain the above copyright notice, this list of conditions and the
18  * following disclaimers.
19  * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
20  * following disclaimers in the documentation and/or other materials provided with the distribution.
21  * - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
22  * endorse or promote products derived from this Software without specific prior written permission.
23  * - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
24  * names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
27  * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * WITH THE SOFTWARE.
31  *
32  *END_COPYRIGHT_BLOCK*/

33
34 // TODO: should this be in the compiler package?
35
package edu.rice.cs.drjava.model.compiler;
36
37 import java.io.IOException JavaDoc;
38 import java.io.File JavaDoc;
39 import java.util.List JavaDoc;
40 import edu.rice.cs.drjava.model.OpenDefinitionsDocument;
41
42 /** Interface for all compiler functionality in the model. The compilation process itself can be monitored through
43  * the CompilerListener interface. The four primary uses of this interface will be to manage listeners, to trigger
44  * compilation of (a) document(s), to handle the results, and to manage available compilers.
45  *
46  * @version $Id: CompilerModel.java 4033 2006-11-16 20:16:51Z rcartwright $
47  */

48 public interface CompilerModel {
49   
50   /** Legal source file name extensions */
51   public static final String JavaDoc[] EXTENSIONS = new String JavaDoc[]{".java", ".dj0", ".dj1", ".dj2"};
52   
53   //----------------------------Locking--------------------------------------//
54

55   /** Returns the lock used to prevent simultaneous compilation and JUnit testing */
56   public Object JavaDoc getCompilerLock();
57   
58   //-------------------------- Listener Management --------------------------//
59

60   /** Add a CompilerListener to the model.
61    * @param listener a listener that reacts to compiler events
62    */

63   public void addListener(CompilerListener listener);
64
65   /** Remove a CompilerListener from the model. If the listener is not currently listening to this model, this method
66    * has no effect.
67    * @param listener a listener that reacts to compiler events
68    */

69   public void removeListener(CompilerListener listener);
70
71   /** Removes all CompilerListeners from this model. */
72   public void removeAllListeners();
73   
74   //-------------------------------- Triggers --------------------------------//
75

76   /** Compiles all documents, which requires that the documents be saved first.
77    * @throws IOException if a filesystem-related problem prevents compilation
78    */

79   public void compileAll() throws IOException JavaDoc;
80   
81   /** Compiles all documents in the project source tree, which requires that the documents be saved first.
82    * @throws IOException if a filesystem-related problem prevents compilation
83    */

84   public void compileProject() throws IOException JavaDoc;
85   
86   /** Compiles the specified documents which must be saved first.
87    * @param docs the documents to be compiled
88    * @throws IOException if a filesystem-related problem prevents compilation
89    */

90   public void compile(List JavaDoc<OpenDefinitionsDocument> docs) throws IOException JavaDoc;
91   
92   /** Compiles a single document which must be saved first.
93    * @param doc the document to be compiled
94    * @throws IOException if a filesystem-related problem prevents compilation
95    */

96   public void compile(OpenDefinitionsDocument doc) throws IOException JavaDoc;
97   
98   //----------------------------- Error Results -----------------------------//
99

100   /** Gets the CompilerErrorModel representing the last compile. */
101   public CompilerErrorModel getCompilerErrorModel();
102   
103   /** Gets the total number of current errors. */
104   public int getNumErrors();
105   
106   /** Resets the compiler error state to have no errors. */
107   public void resetCompilerErrors();
108   
109   //-------------------------- Compiler Management --------------------------//
110

111   /** Returns all registered compilers that are actually available. That is, for all elements in the returned
112    * array, .isAvailable() is true. This method will never return null or a zero-length array. Instead, if
113    * no compiler is registered and available, this will return a one-element array containing an instance of
114    * {@link NoCompilerAvailable}.
115    * @see CompilerRegistry#getAvailableCompilers
116    */

117   public CompilerInterface[] getAvailableCompilers();
118
119   /** Gets the compiler is the "active" compiler.
120    * @see #setActiveCompiler
121    * @see CompilerRegistry#getActiveCompiler
122    */

123   public CompilerInterface getActiveCompiler();
124
125   /** Sets which compiler is the "active" compiler.
126    * @param compiler Compiler to set active.
127    * @see #getActiveCompiler
128    * @see CompilerRegistry#setActiveCompiler
129    */

130   public void setActiveCompiler(CompilerInterface compiler);
131 }
Popular Tags