lexx.parser.ast
Class IncrementAST

java.lang.Object
  |
  +--antlr.BaseAST
        |
        +--antlr.CommonAST
              |
              +--lexx.parser.ast.IncrementAST
All Implemented Interfaces:
antlr.collections.AST, java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
JavaAST

public abstract class IncrementAST
extends antlr.CommonAST
implements java.lang.Cloneable, java.io.Serializable

Incremental Parsing in an OO language

This class extends ANTLRs AST class, therefore your parser must be written in ANLTR

Copyright (c) 2002-2003

Since:
19/03/2003
Version:
1.0
Author:
Mohammed Imran
See Also:
Serialized Form

Field Summary
protected  int length
           
protected  int pos
           
static int ROOTNODE
           
 
Fields inherited from class antlr.CommonAST
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
IncrementAST()
           
 
Method Summary
protected static void changeChildren(IncrementAST parent, java.util.List oldSelectedNodes, java.util.List newNodes)
           
abstract  java.lang.Object clone()
           
protected  boolean contains(int pos)
           
protected  java.util.List getAllChildren(int min, int max)
           
 java.util.List getAllNodes()
           
 java.util.List getAllNodes(int type)
           
 IncrementAST getChild(int type)
           
 IncrementAST getIncrementAST(int pos)
           
protected  IncrementAST getLexxSubTreeAST(int minPos)
          This returns a subtree
 int getMax()
           
 int getMin()
           
protected  java.util.List getPath(int position)
          Returns a path from the beginning of tree to the node
protected static java.util.List getType(java.util.List nodes, int type)
           
protected  void increament(int inc)
          Increments the whole tree
 void increament(int inc, int offset)
          Increments the tree positions
protected  void increament(int inc, int offset, java.util.List exclude)
           
 void initialize(Token tok)
          This method is called inside the ANTLR parser
protected  void insert(java.util.List nodes, IncrementAST before, IncrementAST after)
           
protected  boolean isValid()
           
protected  boolean remove(IncrementAST node)
          This method removes a node from the tree
protected  void setMax(int max)
           
protected  void setMin(int min)
           
protected  void sortLists(java.util.List nodes)
           
 java.lang.String toString()
           
static java.lang.String toString(java.util.List nodes)
           
 void update()
          This method updates the max and min values of whole tree
 void update(java.util.List path)
          This method updates the max and min values of a specific path
abstract  int[] updateTree(java.lang.String originalCode, int offset, int lengthOfChange)
          This is where incremental parsing will actually occur.
abstract  java.util.List walkThruTree(int pos)
          Given a specific position it walks through the AST until it reaches it
abstract  java.util.List walkThruTree(int pos, int type)
          Given a specific position it walks through the AST until it reaches it
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, getNumberOfChildren, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOTNODE

public static final int ROOTNODE
See Also:
Constant Field Values

pos

protected int pos

length

protected int length
Constructor Detail

IncrementAST

public IncrementAST()
Method Detail

clone

public abstract java.lang.Object clone()
Overrides:
clone in class java.lang.Object

walkThruTree

public abstract java.util.List walkThruTree(int pos)
Given a specific position it walks through the AST until it reaches it

Parameters:
pos - the postion to walk to
Returns:
it records (inorder) all the nodes/AST visited until reaching that specific position

walkThruTree

public abstract java.util.List walkThruTree(int pos,
                                            int type)
Given a specific position it walks through the AST until it reaches it

Parameters:
pos - the postion to walk to
type - only include nodes/AST of this type
Returns:
it records (inorder) all the nodes/AST of a specific type visited until reaching that specific position

getChild

public final IncrementAST getChild(int type)
Parameters:
type - please refer to JavaTokenTypes
Returns:
a child if it contains a specific type

getType

protected static java.util.List getType(java.util.List nodes,
                                        int type)

getAllNodes

public final java.util.List getAllNodes()

getAllNodes

public final java.util.List getAllNodes(int type)

sortLists

protected final void sortLists(java.util.List nodes)

toString

public static java.lang.String toString(java.util.List nodes)

initialize

public final void initialize(Token tok)
This method is called inside the ANTLR parser

Specified by:
initialize in interface antlr.collections.AST
Overrides:
initialize in class antlr.CommonAST
Parameters:
tok -

remove

protected final boolean remove(IncrementAST node)
This method removes a node from the tree

Parameters:
node -

changeChildren

protected static void changeChildren(IncrementAST parent,
                                     java.util.List oldSelectedNodes,
                                     java.util.List newNodes)

contains

protected final boolean contains(int pos)

insert

protected final void insert(java.util.List nodes,
                            IncrementAST before,
                            IncrementAST after)

updateTree

public abstract int[] updateTree(java.lang.String originalCode,
                                 int offset,
                                 int lengthOfChange)
                          throws java.lang.Exception
This is where incremental parsing will actually occur. This object contains the old AST of the source code. This method updates this AST

Parameters:
originalCode - The changed test
offset - The position where the text chagned
lengthOfChange - The amount of text that was inserted/removed
Returns:
the region of coding that has changed. This may be useful if you want to update a syntax highlighter
Throws:
java.lang.Exception

increament

public final void increament(int inc,
                             int offset)
Increments the tree positions

Parameters:
inc - amount to increment
offset - the position where incrementing should occur

increament

protected final void increament(int inc,
                                int offset,
                                java.util.List exclude)

increament

protected final void increament(int inc)
Increments the whole tree


getIncrementAST

public final IncrementAST getIncrementAST(int pos)

getLexxSubTreeAST

protected final IncrementAST getLexxSubTreeAST(int minPos)
This returns a subtree

Parameters:
minPos -
Returns:

isValid

protected final boolean isValid()

getPath

protected final java.util.List getPath(int position)
Returns a path from the beginning of tree to the node

Parameters:
position -
Returns:

getAllChildren

protected final java.util.List getAllChildren(int min,
                                              int max)

getMax

public final int getMax()

getMin

public final int getMin()

update

public final void update()
This method updates the max and min values of whole tree


update

public final void update(java.util.List path)
This method updates the max and min values of a specific path


toString

public final java.lang.String toString()
Specified by:
toString in interface antlr.collections.AST
Overrides:
toString in class antlr.BaseAST

setMax

protected final void setMax(int max)

setMin

protected final void setMin(int min)