public class ProgressPatternWorker.ProgressAstHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.Integer,java.lang.Integer> |
attrMethTypes
Map with the type of all known attributes and methods
|
Constructor and Description |
---|
ProgressAstHelper() |
Modifier and Type | Method and Description |
---|---|
Aast |
createProgressAst(int type,
Aast parent)
General purpose Progress AST creation function which can create a
ProgressAst node using the passed token type and the
empty string as the text of the node. |
Aast |
createProgressAst(int type,
Aast parent,
int index)
General purpose Progress AST creation function which can create a
ProgressAst node using the passed token type and the
empty string as the text of the node. |
Aast |
createProgressAst(int type,
java.lang.String text,
Aast parent)
General purpose Progress AST creation function which can create a
ProgressAst node using the passed token type and text
and then it will attach that node to the specified parent as the
last child. |
Aast |
createProgressAst(int type,
java.lang.String text,
Aast parent,
int index)
General purpose Progress AST creation function which can create a
ProgressAst node using the passed token type and text
and then it will attach that node to the specified parent at the
given index. |
ShadowNode |
createShadow(int type,
java.lang.String text)
Create a shadow node representing the given token type and text.
|
long |
getClosestPeerId(Aast start)
Search the given AST node and up each ancestor node in the path to the root to find the
first instance of the 'peerid' annotation.
|
java.util.Comparator<? extends Aast> |
getSortComparator()
Helper to return a comparator that can be used to sort a list by the order of
the nodes in the file (line and then column).
|
void |
insertInStream(Aast node,
Aast existing,
boolean before)
Insert the node in the stream before or after an existing node.
|
void |
insertInStream(ShadowNode node,
Aast existing,
boolean before)
Insert the specific shadow node (and no other nodes) into the stream before or after
an existing node.
|
int |
lookupAttributeOrMethod(int ktype)
Searches the attribute and method dictionary for a token type matching
the passed keyword.
|
int |
lookupKeywordToken(java.lang.String text)
Given a partial (abbreviated) or full keyword text, lookup its token type.
|
java.lang.String |
lookupTokenName(int type)
Translates an integer value of a parser token type into the associated
human readable text representation.
|
private java.util.Map<java.lang.Integer,java.lang.Integer> attrMethTypes
public long getClosestPeerId(Aast start)
start
- The node at which to start the search.public Aast createProgressAst(int type, Aast parent)
ProgressAst
node using the passed token type and the
empty string as the text of the node. It will then attach that node
to the specified parent as the last child.type
- The token type for the Progress AST.parent
- The parent AST node.null
if
the parent is invalid, if the type is not valid or on any
unexpected error during AST creation.public Aast createProgressAst(int type, java.lang.String text, Aast parent)
ProgressAst
node using the passed token type and text
and then it will attach that node to the specified parent as the
last child.type
- The token type for the Progress AST.text
- The text for the AST.parent
- The parent AST node.null
if
the parent is invalid, if the type is not valid or on any
unexpected error during AST creation.public Aast createProgressAst(int type, Aast parent, int index)
ProgressAst
node using the passed token type and the
empty string as the text of the node. It will then attach that node
to the specified parent at the given index.type
- The token type for the Progress AST.parent
- The parent AST node.index
- 0 to insert as the first child, -1 to insert as the last
child or a 0-based index to specify an exact child index
at which to insert the new child. All current children at
that index or at a greater index, are moved right. If the
index is greater than the current number of children, the
new child will be added at the end.null
if
the parent is invalid, if the type is not valid or on any
unexpected error during AST creation.public Aast createProgressAst(int type, java.lang.String text, Aast parent, int index)
ProgressAst
node using the passed token type and text
and then it will attach that node to the specified parent at the
given index.type
- The token type for the Progress AST.text
- The text for the AST.parent
- The parent AST node.index
- 0 to insert as the first child, -1 to insert as the last
child or a 0-based index to specify an exact child index
at which to insert the new child. All current children at
that index or at a greater index, are moved right. If the
index is greater than the current number of children, the
new child will be added at the end.null
if
the parent is invalid, if the type is not valid or on any
unexpected error during AST creation.public ShadowNode createShadow(int type, java.lang.String text)
copy
node
exists. It will be parented by the root node of that tree, but it will not be
in the list of children of the root node (the parent linkage is created but the
child linkages are not created). This is how all shadow nodes exist. The id will
be properly set but there will be no line/column numbers and the left/right
nodes will be null
.type
- The token type for the Progress AST.text
- The text for the AST.public void insertInStream(Aast node, Aast existing, boolean before)
node
- The node to insert. If the existing node has shadow nodes on the insertion
side, it will be linked to this node.existing
- The already existing node relative to whom the insertion will occur. Any
shadow nodes already connected to the existing node on the insertion side
will be de-linked from this node and re-linked on the other side of the
insertion node.before
- true
to insert before and false
to insert after.public void insertInStream(ShadowNode node, Aast existing, boolean before)
The shadow node should not have any existing left or right linkages!
node
- The shadow node to insert. Both sides will be linked if the existing
node has linkages on both sides.existing
- The already existing node relative to whom the insertion will occur. Any
shadow nodes already connected to the existing node on the insertion side
will be de-linked from this node and re-linked on the other side of the
insertion node.before
- true
to insert before and false
to insert after.public java.lang.String lookupTokenName(int type)
type
- The integer token type.null
if
no match was found.public java.util.Comparator<? extends Aast> getSortComparator()
public int lookupKeywordToken(java.lang.String text)
text
- The keyword text.token type
or -1
if not found.public int lookupAttributeOrMethod(int ktype)
ktype
- Token type of the keyword to lookup.