cs132.util
Class Problem

java.lang.Object
  extended by cs132.util.Problem

public final class Problem
extends Object

Used to describe a "problem", while referring to some kind of source code. Consists of a "primary" location as well as any number of additional locations.

For example, for a problem like "unknown variable", you'd probably just have a primary location that refers to the variable reference and a message that says "unknown variable".

For something like "duplicate variable name", you might have a primary location that refers to the declaration and a message that says "duplicate variable name" along with an additional location that points to the original declaration of that name with a message like "original declaration".


Nested Class Summary
static class Problem.Ref
          A pairing of a SourcePos and a message.
 
Field Summary
 List<Problem.Ref> additional
          Any number of additional locations and messages.
 Problem.Ref primary
          The primary location and primary error message.
 
Constructor Summary
Problem(Problem.Ref primary)
           
Problem(Problem.Ref primary, List<Problem.Ref> additional)
           
Problem(SourcePos sourcePos, String message)
          Convenience constructor that creates a Problem with just a primary reference.
Problem(SourcePos sourcePos, String message, SourcePos additionalSourcePos, String additionalMessage)
          Convenience constructor that creates a Problem with a primary reference and one additional reference.
 
Method Summary
 String toString()
           
 void toString(StringBuilder buf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

primary

public final Problem.Ref primary
The primary location and primary error message.


additional

public final List<Problem.Ref> additional
Any number of additional locations and messages.

Constructor Detail

Problem

public Problem(Problem.Ref primary,
               List<Problem.Ref> additional)

Problem

public Problem(Problem.Ref primary)

Problem

public Problem(SourcePos sourcePos,
               String message)
Convenience constructor that creates a Problem with just a primary reference.


Problem

public Problem(SourcePos sourcePos,
               String message,
               SourcePos additionalSourcePos,
               String additionalMessage)
Convenience constructor that creates a Problem with a primary reference and one additional reference.

Method Detail

toString

public String toString()
Overrides:
toString in class Object

toString

public void toString(StringBuilder buf)