|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.drjava.model.compiler.DefaultCompilerModel
public class DefaultCompilerModel
Default implementation of the CompilerModel interface. This implementation is used for normal DrJava execution (as opposed to testing DrJava). TO DO: convert edu.rice.cs.util.Pair to edu.rice.cs.plt.tuple.Pair; requires making the same conversion in javalanglevels.
| Field Summary | |
|---|---|
private CompilerInterface |
_active
Current compiler -- one of _compilers, or a NoCompilerAvailable |
private CompilerErrorModel |
_compilerErrorModel
The error model containing all current compiler errors. |
private java.lang.Object |
_compilerLock
The lock providing mutual exclustion between compilation and unit testing |
private java.util.List<CompilerInterface> |
_compilers
The available compilers |
LanguageLevelStackTraceMapper |
_LLSTM
The LanguageLevelStackTraceMapper that helps translate .java line numbers to .dj* line numbers when an error is thrown |
private static Log |
_log
for logging debug info |
private GlobalModel |
_model
The global model to which this compiler model belongs. |
private CompilerEventNotifier |
_notifier
Manages listeners to this model. |
| Constructor Summary | |
|---|---|
DefaultCompilerModel(GlobalModel m,
java.lang.Iterable<? extends CompilerInterface> compilers)
Main constructor. |
|
| Method Summary | |
|---|---|
private void |
_compileFiles(java.util.List<java.io.File> files,
java.io.File buildDir)
Compile the given files and update the model with any errors that result. |
private java.util.List<java.io.File> |
_compileLanguageLevelsFiles(java.util.List<java.io.File> files,
java.util.List<DJError> errors,
java.lang.Iterable<java.io.File> classPath,
java.lang.Iterable<java.io.File> bootClassPath)
Compiles the language levels files in the list. |
private void |
_distributeErrors(java.util.List<? extends DJError> errors)
Sorts the given array of CompilerErrors and divides it into groups based on the file, giving each group to the appropriate OpenDefinitionsDocument, opening files if necessary. |
private void |
_doCompile(java.util.List<OpenDefinitionsDocument> docs)
Compile the given documents. |
private java.util.LinkedList<DJError> |
_parseExceptions2CompilerErrors(java.util.LinkedList<JExprParseException> pes)
Converts JExprParseExceptions thrown by the JExprParser in language levels to CompilerErrors. |
private boolean |
_prepareForCompile()
Check that there are no unsaved or untitled files currently open. |
private static java.util.List<java.io.File> |
_testFileSort(java.util.List<java.io.File> files)
Reorders files so that all file names containing "Test" are at the end. |
private java.util.LinkedList<DJError> |
_visitorErrors2CompilerErrors(java.util.LinkedList<Pair<java.lang.String,JExpressionIF>> visitorErrors)
Converts errors thrown by the language level visitors to CompilerErrors. |
void |
addCompiler(CompilerInterface compiler)
Add a compiler to the active list |
void |
addListener(CompilerListener listener)
Adds a CompilerListener to the model. |
void |
compile(java.util.List<OpenDefinitionsDocument> defDocs)
Compiles all of the given files. |
void |
compile(OpenDefinitionsDocument doc)
Compiles the given file. |
void |
compileAll()
Compile all open documents. |
void |
compileProject()
Compiles all documents in the project source tree. |
CompilerInterface |
getActiveCompiler()
Gets the compiler that is the "active" compiler. |
java.lang.Iterable<CompilerInterface> |
getAvailableCompilers()
Returns all registered compilers that are actually available. |
CompilerErrorModel |
getCompilerErrorModel()
Gets the CompilerErrorModel representing the last compile. |
java.lang.Object |
getCompilerLock()
Returns the lock used to prevent simultaneous compilation and JUnit testing |
LanguageLevelStackTraceMapper |
getLLSTM()
returns the LanguageLevelStackTraceMapper |
int |
getNumCompErrors()
Gets the total number of current compiler errors. |
int |
getNumErrors()
Gets the total number of errors in this compiler model. |
int |
getNumWarnings()
Gets the total number of current warnings. |
void |
removeAllListeners()
Removes all CompilerListeners from this model. |
void |
removeListener(CompilerListener listener)
Removes a CompilerListener from the model. |
void |
resetCompilerErrors()
Resets the compiler error state to have no errors. |
void |
setActiveCompiler(CompilerInterface compiler)
Sets which compiler is the "active" compiler. |
void |
smartDeleteClassFiles(java.util.Map<java.io.File,java.util.Set<java.lang.String>> sourceToTopLevelClassMap)
Delete the .class files that match the following pattern: XXX.dj? --> XXX.class XXX$*.class |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static Log _log
private final java.util.List<CompilerInterface> _compilers
private CompilerInterface _active
private final CompilerEventNotifier _notifier
private final GlobalModel _model
private CompilerErrorModel _compilerErrorModel
private java.lang.Object _compilerLock
public LanguageLevelStackTraceMapper _LLSTM
| Constructor Detail |
|---|
public DefaultCompilerModel(GlobalModel m,
java.lang.Iterable<? extends CompilerInterface> compilers)
m - the GlobalModel that is the source of documents for this CompilerModelcompilers - The compilers to use. The first will be made active; all are assumed
to be available. An empty list is acceptable.| Method Detail |
|---|
public java.lang.Object getCompilerLock()
getCompilerLock in interface CompilerModelpublic void addListener(CompilerListener listener)
addListener in interface CompilerModellistener - A listener that reacts to compiler events.public void removeListener(CompilerListener listener)
removeListener in interface CompilerModellistener - a listener that reacts to compiler events
This operation is synchronized by the readers/writers protocol in EventNotifierpublic void removeAllListeners()
removeAllListeners in interface CompilerModel
public void compileAll()
throws java.io.IOException
Before compiling, all unsaved and untitled documents are saved, and compilation ends if the user cancels this step. The compilation classpath and sourcepath includes the build directory (if it exists), the source roots, the project "extra classpath" (if it exists), the global "extra classpath", and the current JVM's classpath (which includes drjava.jar, containing JUnit classes).
This method formerly only compiled documents which were out of sync with their class file, as a performance optimization. However, bug #634386 pointed out that unmodified files could depend on modified files, in which case this command would not recompile a file in some situations when it should. Since we value correctness over performance, we now always compile all open documents.
compileAll in interface CompilerModeljava.io.IOException - if a filesystem-related problem prevents compilation
public void compileProject()
throws java.io.IOException
Before compiling, all unsaved and untitled documents are saved, and compilation ends if the user cancels this step. The compilation classpath and sourcepath includes the build directory (if it exists), the source roots, the project "extra classpath" (if it exists), the global "extra classpath", and the current JVM's classpath (which includes drjava.jar, containing JUnit classes).
This method formerly only compiled documents which were out of sync with their class file, as a performance optimization. However, bug #634386 pointed out that unmodified files could depend on modified files, in which case this command would not recompile a file in some situations when it should. Since we value correctness over performance, we now always compile all open documents.
compileProject in interface CompilerModeljava.io.IOException - if a filesystem-related problem prevents compilation
public void compile(java.util.List<OpenDefinitionsDocument> defDocs)
throws java.io.IOException
Before compiling, all unsaved and untitled documents are saved, and compilation ends if the user cancels this step. The compilation classpath and sourcepath includes the build directory (if it exists), the source roots, the project "extra classpath" (if it exists), the global "extra classpath", and the current JVM's classpath (which includes drjava.jar, containing JUnit classes).
This method formerly only compiled documents which were out of sync with their class file, as a performance optimization. However, bug #634386 pointed out that unmodified files could depend on modified files, in which case this command would not recompile a file in some situations when it should. Since we value correctness over performance, we now always compile all open documents.
compile in interface CompilerModeldefDocs - the documents to be compiled
java.io.IOException - if a filesystem-related problem prevents compilation
public void compile(OpenDefinitionsDocument doc)
throws java.io.IOException
Before compiling, all unsaved and untitled documents are saved, and compilation ends if the user cancels this step. The compilation classpath and sourcepath includes the build directory (if it exists), the source roots, the project "extra classpath" (if it exists), the global "extra classpath", and the current JVM's classpath (which includes drjava.jar, containing JUnit classes).
This method formerly only compiled documents which were out of sync with their class file, as a performance optimization. However, bug #634386 pointed out that unmodified files could depend on modified files, in which case this command would not recompile a file in some situations when it should. Since we value correctness over performance, we now always compile all open documents.
compile in interface CompilerModeldoc - the document to be compiled
java.io.IOException - if a filesystem-related problem prevents compilationprivate boolean _prepareForCompile()
private void _doCompile(java.util.List<OpenDefinitionsDocument> docs)
throws java.io.IOException
java.io.IOExceptionprivate java.util.LinkedList<DJError> _parseExceptions2CompilerErrors(java.util.LinkedList<JExprParseException> pes)
private java.util.LinkedList<DJError> _visitorErrors2CompilerErrors(java.util.LinkedList<Pair<java.lang.String,JExpressionIF>> visitorErrors)
private void _compileFiles(java.util.List<java.io.File> files,
java.io.File buildDir)
throws java.io.IOException
files - The files to be compiledbuildDir - The output directory for all the .class files; @code{null} means output to the same
directory as the source file
java.io.IOExceptionprivate static java.util.List<java.io.File> _testFileSort(java.util.List<java.io.File> files)
private java.util.List<java.io.File> _compileLanguageLevelsFiles(java.util.List<java.io.File> files,
java.util.List<DJError> errors,
java.lang.Iterable<java.io.File> classPath,
java.lang.Iterable<java.io.File> bootClassPath)
private void _distributeErrors(java.util.List<? extends DJError> errors)
throws java.io.IOException
java.io.IOExceptionpublic CompilerErrorModel getCompilerErrorModel()
getCompilerErrorModel in interface CompilerModelpublic int getNumErrors()
getNumErrors in interface CompilerModelpublic int getNumCompErrors()
public int getNumWarnings()
public void resetCompilerErrors()
resetCompilerErrors in interface CompilerModelpublic java.lang.Iterable<CompilerInterface> getAvailableCompilers()
NoCompilerAvailable.ONLY.
getAvailableCompilers in interface CompilerModelpublic CompilerInterface getActiveCompiler()
getActiveCompiler in interface CompilerModelsetActiveCompiler(edu.rice.cs.drjava.model.compiler.CompilerInterface)public void setActiveCompiler(CompilerInterface compiler)
setActiveCompiler in interface CompilerModelcompiler - Compiler to set active.
java.lang.IllegalArgumentException - If the compiler is not in the list of available compilersgetActiveCompiler()public void addCompiler(CompilerInterface compiler)
addCompiler in interface CompilerModelpublic void smartDeleteClassFiles(java.util.Map<java.io.File,java.util.Set<java.lang.String>> sourceToTopLevelClassMap)
sourceToTopLevelClassMap - a map from directories to classes in thempublic LanguageLevelStackTraceMapper getLLSTM()
getLLSTM in interface CompilerModel
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||