org.prorefactor.treeparser
Class ParseUnit

java.lang.Object
  extended by org.prorefactor.treeparser.ParseUnit
Direct Known Subclasses:
AnalystParseUnit, CompileUnit

public class ParseUnit
extends java.lang.Object

Provides parse unit information, such as the symbol table and a reference to the AST. TreeParser01 calls symbolUsage() in this class in order to build the symbol table.


Field Summary
static int CONNECTED
          The JPNode tree is "connected" to Proparse, by default
static int DEFAULT
          The JPNode tree is "connected" to Proparse, by default
static int DISCONNECTED
          Working with JPNode in disconnected mode may not yet be fully supported.
protected  java.io.File file
           
protected  PUB pub
           
protected  RefactorSession refpack
           
protected  int style
           
 
Constructor Summary
ParseUnit(java.io.File file)
           
 
Method Summary
 java.io.File getFile()
           
 java.lang.String[] getFileIndex()
          Get the file index, either from the PUB file or from the parser, whichever was used to get the tree.
 IncludeRef getMacroGraph()
          This will trigger a parse if the PUB is out of date.
 MacroRef[] getMacroSourceArray()
          This is just a shortcut for calling getMacroGraph() and MacroLevel.sourceArray().
 PUB getPUB()
          Get or create a PUB
 SymbolScopeRoot getRootScope()
           
 ProgramRootNode getTopNode()
          Get the syntax tree top (Program_root) node
 void loadOrBuildPUB()
          Load from PUB, or build PUB if it's out of date.
 void parse()
           
 ParseUnit setPUB(PUB pub)
           
 void setRootScope(SymbolScopeRoot rootScope)
           
 void setTopNode(JPNode topNode)
          Set the syntax tree top (Program_root) node.
 void treeParser(IJPTreeParser tp)
          Run any IJPTreeParser against the AST.
 void treeParser01()
          Run TreeParser01.
 void treeParser01(TP01Action action)
          Run TreeParser01 with any TP01Action object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTED

public static final int CONNECTED
The JPNode tree is "connected" to Proparse, by default

See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
The JPNode tree is "connected" to Proparse, by default

See Also:
Constant Field Values

DISCONNECTED

public static final int DISCONNECTED
Working with JPNode in disconnected mode may not yet be fully supported. See JPNode docs.

See Also:
Constant Field Values

style

protected int style

file

protected java.io.File file

pub

protected PUB pub

refpack

protected RefactorSession refpack
Constructor Detail

ParseUnit

public ParseUnit(java.io.File file)
Method Detail

getFile

public java.io.File getFile()

getFileIndex

public java.lang.String[] getFileIndex()
Get the file index, either from the PUB file or from the parser, whichever was used to get the tree. The return is the array of file names. The file at index zero is always the compile unit. The others are include files. The array index position corresponds to JPNode.getFileIndex().

See Also:
JPNode.getFilenames()

getMacroGraph

public IncludeRef getMacroGraph()
                         throws RefactorException,
                                java.io.IOException
This will trigger a parse if the PUB is out of date.

Throws:
RefactorException
java.io.IOException

getMacroSourceArray

public MacroRef[] getMacroSourceArray()
                               throws RefactorException,
                                      java.io.IOException
This is just a shortcut for calling getMacroGraph() and MacroLevel.sourceArray(). Build and return an array of the MacroRef objects, which would map to the SOURCENUM attribute from JPNode. Built simply by walking the tree and adding every MacroRef to the array.

Throws:
RefactorException
java.io.IOException
See Also:
MacroLevel.sourceArray(MacroRef)

getPUB

public PUB getPUB()
Get or create a PUB


getRootScope

public SymbolScopeRoot getRootScope()

getTopNode

public ProgramRootNode getTopNode()
Get the syntax tree top (Program_root) node


loadOrBuildPUB

public void loadOrBuildPUB()
                    throws RefactorException,
                           java.io.IOException
Load from PUB, or build PUB if it's out of date. TreeParser01 is run in order to build the PUB. If the PUB was up to date, then TreeParser01 is run after the PUB is loaded. (Either way, the symbol tables etc. are available.)

Throws:
RefactorException
java.io.IOException

parse

public void parse()
           throws RefactorException
Throws:
RefactorException

setPUB

public ParseUnit setPUB(PUB pub)

setRootScope

public void setRootScope(SymbolScopeRoot rootScope)

setTopNode

public void setTopNode(JPNode topNode)
Set the syntax tree top (Program_root) node.


treeParser

public void treeParser(IJPTreeParser tp)
                throws RefactorException
Run any IJPTreeParser against the AST. This will call parse() if the JPNode AST has not already been built.

Throws:
RefactorException

treeParser01

public void treeParser01()
                  throws RefactorException
Run TreeParser01. Takes care of calling parse() first, if that has not already been done.

Throws:
RefactorException

treeParser01

public void treeParser01(TP01Action action)
                  throws RefactorException
Run TreeParser01 with any TP01Action object. Takes care of calling parse() first, if that has not already been done.

Throws:
RefactorException


Copyright © 2008 Joanju Software. All Rights Reserved.