modesteditor.core.model
Class ModestSimulation

java.lang.Object
  extended by modesteditor.core.model.ModestSimulation

public class ModestSimulation
extends java.lang.Object

Maintains the high-level representation of an MoDeST simulation, including the parse tree and the identifiers defined in the program.

An ModestSimulation works on one document being edited in the workspace. It has to be updated by the ModestEditor whenever the document is changed.


Constructor Summary
ModestSimulation(org.eclipse.jface.text.IDocument document)
          Creates a ModestSimulation attached to the given document.
 
Method Summary
 void addListener(IModestSimulationListener listener)
          Adds a listener to this program.
 antlr.collections.AST getCurrentAST()
           
 Model[] getModels()
          Returns the list of identifiers bound by the program.
 org.eclipse.jface.text.IRegion[] getProblems()
          Returns the regions where problems were found in the simulation.
 java.util.ArrayList<java.lang.String> getProcesses()
           
 Process getSim()
          Returns the simulation's root Process which is first updated if the document isn't parsed yet.
 java.util.ArrayList<java.lang.String> getVariables()
           
 org.eclipse.jface.text.IRegion[] getWarnings()
          Returns the warnings for unused variables.
 void removeListener(IModestSimulationListener listener)
          Removes the listener from this program.
 void update()
          Updates the representation of the program.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModestSimulation

public ModestSimulation(org.eclipse.jface.text.IDocument document)
Creates a ModestSimulation attached to the given document. The ModestSimulation does not update itself when the document changes.

Method Detail

getSim

public Process getSim()
Returns the simulation's root Process which is first updated if the document isn't parsed yet.

Returns:
the root of the parse tree.

getModels

public Model[] getModels()
Returns the list of identifiers bound by the program. See Model for details.


getProblems

public org.eclipse.jface.text.IRegion[] getProblems()
Returns the regions where problems were found in the simulation. In this version, only syntax errors are found.


getWarnings

public org.eclipse.jface.text.IRegion[] getWarnings()
Returns the warnings for unused variables.

Returns:
the regions with unused variables.

getVariables

public java.util.ArrayList<java.lang.String> getVariables()
Returns:
the string representation of all variables and exceptions

getProcesses

public java.util.ArrayList<java.lang.String> getProcesses()
Returns:
the process names used for completion

update

public void update()
Updates the representation of the program. This method should be called by the editor when the document is changed.


addListener

public void addListener(IModestSimulationListener listener)
Adds a listener to this program. The listener will be notified when the program is updated.


removeListener

public void removeListener(IModestSimulationListener listener)
Removes the listener from this program. If the listener was not added to the program, nothing happens.


getCurrentAST

public antlr.collections.AST getCurrentAST()
Returns:
the currentAST or null if the AST isn't valid.