public class CodeBlock
extends java.lang.Object
CodeBlocks provides a
means of remembering where variables are defined, as well as their scopes.VariableDeclaration| Constructor and Description |
|---|
CodeBlock(int start)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
CodeBlock |
addChildCodeBlock(int start)
Creates and returns a child (nested) code block.
|
void |
addVariable(VariableDeclaration varDec)
Adds a variable declaration.
|
boolean |
contains(int offset)
Returns whether this code block contains a given offset.
|
CodeBlock |
getChildCodeBlock(int index)
Returns a child code block.
|
int |
getChildCodeBlockCount()
Returns the number of child code blocks.
|
CodeBlock |
getDeepestCodeBlockContaining(int offs)
Returns the deepest code block nested under this one (or this one
itself) containing a given offset.
|
int |
getEndOffset()
Returns the end offset of this code block.
|
CodeBlock |
getParent()
Returns the parent code block.
|
int |
getStartOffset()
Returns the start offset of this code block.
|
VariableDeclaration |
getVariableDeclaration(int index)
Returns a variable declaration.
|
int |
getVariableDeclarationCount()
Returns the number of variable declarations in this code block.
|
java.util.List<VariableDeclaration> |
getVariableDeclarationsBefore(int offs)
Returns all local variables declared before a given offset, both in
this code block and in all parent blocks.
|
void |
setEndOffset(int end)
Sets the end offset of this code block.
|
public CodeBlock(int start)
start - The starting offset of the code block.public CodeBlock addChildCodeBlock(int start)
start - The starting offset of the nested code block.public void addVariable(VariableDeclaration varDec)
varDec - The variable declaration.public boolean contains(int offset)
offset - The offset.public CodeBlock getChildCodeBlock(int index)
index - The index of the child code block.getChildCodeBlockCount()public int getChildCodeBlockCount()
getChildCodeBlock(int)public CodeBlock getDeepestCodeBlockContaining(int offs)
offs - The offset to look for.null if this code block and none of its children
contain the offset.public int getEndOffset()
getStartOffset(),
setEndOffset(int)public CodeBlock getParent()
null if there isn't one.public int getStartOffset()
getEndOffset()public VariableDeclaration getVariableDeclaration(int index)
index - The index of the declaration.getVariableDeclarationCount()public int getVariableDeclarationCount()
getVariableDeclaration(int)public java.util.List<VariableDeclaration> getVariableDeclarationsBefore(int offs)
offs - The offset.VariableDeclarations, or an empty list of none were
declared before the offset.public void setEndOffset(int end)
end - The end offset.getEndOffset()