edu.rice.cs.drjava.model.compiler
Class CompilerErrorModel

java.lang.Object
  extended by edu.rice.cs.drjava.model.compiler.CompilerErrorModel
Direct Known Subclasses:
JUnitErrorModel

public class CompilerErrorModel
extends Object

Contains the CompilerErrors for a particular file after a compile has ended.

Version:
$Id: CompilerErrorModel.java 4691 2008-12-02 23:33:27Z dlsmith $

Constructor Summary
CompilerErrorModel()
          Constructs an empty CompilerErrorModel with no errors and a dummy global model.
CompilerErrorModel(DJError[] errors, GlobalModel model)
          Constructs a new CompilerErrorModel with specified global model.
 
Method Summary
 DJError getError(int idx)
          Accessor for errors maintained here.
 DJError getErrorAtOffset(OpenDefinitionsDocument odd, int offset)
          This method finds and returns the error that is at the given offset
 int getNumCompErrors()
          Returns the number of CompilerErrors that are compiler errors
 int getNumErrors()
          Returns the number of CompilerErrors.
 int getNumWarnings()
          Returns the number of CompilerErrors that are warnings
 Position getPosition(DJError error)
          Returns the position of the given error in the document representing its file.
 boolean hasErrorsWithPositions(OpenDefinitionsDocument odd)
          This function tells if there are errors with source locations associated with the given file.
 boolean hasOnlyWarnings()
          Checks whether all CompilerErrors contained here are actually warnings.
 String toString()
          Prints out this model's errors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompilerErrorModel

public CompilerErrorModel()
Constructs an empty CompilerErrorModel with no errors and a dummy global model.


CompilerErrorModel

public CompilerErrorModel(DJError[] errors,
                          GlobalModel model)
Constructs a new CompilerErrorModel with specified global model. Performed in DefaultGlobalModel construction and after compilation has been performed.

Parameters:
errors - the list of DJError's (or a subclass).
model - is the model to find documents from
Method Detail

getError

public DJError getError(int idx)
Accessor for errors maintained here.

Parameters:
idx - the index of the error to retrieve
Returns:
the error at index idx
Throws:
NullPointerException - if this object was improperly initialized
ArrayIndexOutOfBoundsException - if !(0 <= idx < this.getNumErrors())

getPosition

public Position getPosition(DJError error)
Returns the position of the given error in the document representing its file.


getNumErrors

public int getNumErrors()
Returns the number of CompilerErrors.


getNumCompErrors

public int getNumCompErrors()
Returns the number of CompilerErrors that are compiler errors


getNumWarnings

public int getNumWarnings()
Returns the number of CompilerErrors that are warnings


toString

public String toString()
Prints out this model's errors.

Overrides:
toString in class Object

getErrorAtOffset

public DJError getErrorAtOffset(OpenDefinitionsDocument odd,
                                int offset)
This method finds and returns the error that is at the given offset

Parameters:
odd - the OpenDefinitionsDocument where you want to find the error at the caret
offset - the offset into the document
Returns:
the DJError at the given offset, null if no error corresponds to this location

hasErrorsWithPositions

public boolean hasErrorsWithPositions(OpenDefinitionsDocument odd)
This function tells if there are errors with source locations associated with the given file.


hasOnlyWarnings

public boolean hasOnlyWarnings()
Checks whether all CompilerErrors contained here are actually warnings. This would indicate that there were no "real" errors, so output is valid.

Returns:
false if any error contained here is not a warning, true otherwise