public class CodeBlock
extends java.lang.Object
This class implements the Member interface because a block
can be a member (say, a static block in a class declaration), but usually
it's not actually a Member, but something else, e.g. the body
of a method, or the content of an if-statement, etc.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NAME
The name of all
CodeBlocks. |
| Constructor and Description |
|---|
CodeBlock(boolean isStatic,
Offset startOffs) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(CodeBlock child)
Adds a child code block to this code block.
|
void |
addLocalVariable(LocalVariable localVar)
Adds a local variable to this code block.
|
boolean |
containsOffset(int offs)
Returns whether this code block contains the specified offset.
|
CodeBlock |
getChildBlock(int index)
Returns the specified child block.
|
int |
getChildBlockCount() |
CodeBlock |
getDeepestCodeBlockContaining(int offs)
Returns the deepest code block nested under this one (or this one
itself) containing a given offset.
|
java.lang.String |
getDocComment()
Returns the doc comment for this member.
|
LocalVariable |
getLocalVar(int index)
Returns the specified local variable.
|
int |
getLocalVarCount() |
java.util.List<LocalVariable> |
getLocalVarsBefore(int offs)
Returns all local variables declared before a given offset, both in
this code block and in all parent blocks.
|
Modifiers |
getModifiers()
Returns the modifiers of this member.
|
java.lang.String |
getName()
Returns the "name" of this node.
|
int |
getNameEndOffset()
Returns the end offset of the "name" of this node.
|
int |
getNameStartOffset()
Returns the start offset of the "name" of this node.
|
CodeBlock |
getParent() |
TypeDeclaration |
getParentTypeDeclaration()
Returns the parent type declaration of this member.
|
Type |
getType()
Returns
null, since blocks don't have types. |
boolean |
isDeprecated()
Returns whether this member is deprecated.
|
boolean |
isStatic()
Returns whether this block is a static block (in a class declaration).
|
void |
setDeclarationEndOffset(Offset end) |
protected void |
setDeclarationOffsets(Offset start,
Offset end)
Sets the start and end offsets of this node.
|
void |
setParent(CodeBlock parent) |
void |
setParentTypeDeclaration(TypeDeclaration dec)
Sets the parent type declaration of this member.
|
java.lang.String |
toString()
Returns the name of this node (e.g.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, getNameEndOffset, getNameStartOffsetpublic static final java.lang.String NAME
CodeBlocks.public CodeBlock(boolean isStatic,
Offset startOffs)
public void add(CodeBlock child)
child - The child code block to add.getChildBlock(int)public void addLocalVariable(LocalVariable localVar)
localVar - The local variable to add.getLocalVar(int)public boolean containsOffset(int offs)
offs - The offset.public CodeBlock getChildBlock(int index)
index - The index of the child block.getChildBlockCount()public int getChildBlockCount()
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 java.lang.String getDocComment()
Memberpublic LocalVariable getLocalVar(int index)
index - The index of the variable.getLocalVarCount()public int getLocalVarCount()
public java.util.List<LocalVariable> getLocalVarsBefore(int offs)
offs - The offset.LocalVariables, or an empty list of none were
declared before the offset.public Modifiers getModifiers()
Memberpublic CodeBlock getParent()
public Type getType()
null, since blocks don't have types.null always.public boolean isDeprecated()
Memberpublic boolean isStatic()
isStatic in interface MemberMember.getModifiers()public void setParent(CodeBlock parent)
public TypeDeclaration getParentTypeDeclaration()
MembergetParentTypeDeclaration in interface MemberMember.setParentTypeDeclaration(TypeDeclaration)public void setParentTypeDeclaration(TypeDeclaration dec)
setParentTypeDeclaration in interface Memberdec - The parent type declaration.Member.getParentTypeDeclaration()public java.lang.String getName()
CodeBlocks
it will be NAME.Note that this may not be unique. For example, a class with an overloaded method will have multiple methods with the same "name," just with different signatures.
public int getNameEndOffset()
getNameEndOffset in interface ASTNodepublic int getNameStartOffset()
getNameStartOffset in interface ASTNodepublic void setDeclarationEndOffset(Offset end)
protected void setDeclarationOffsets(Offset start, Offset end)
start - The start offset.end - The end offset.public java.lang.String toString()
getName()).
Subclasses can override this method if appropriate.toString in class java.lang.Object