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) |
void |
addLocalVariable(LocalVariable localVar) |
boolean |
containsOffset(int offs) |
CodeBlock |
getChildBlock(int index) |
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() |
LocalVariable |
getLocalVar(int index) |
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() |
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() |
Type |
getType()
Returns
null, since blocks don't have types. |
boolean |
isDeprecated() |
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) |
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)
public void addLocalVariable(LocalVariable localVar)
public boolean containsOffset(int offs)
public CodeBlock getChildBlock(int index)
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()
public LocalVariable getLocalVar(int index)
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()
public CodeBlock getParent()
public Type getType()
null, since blocks don't have types.null always.public boolean isDeprecated()
public boolean isStatic()
isStatic in interface MemberMember.getModifiers()public void setParent(CodeBlock parent)
public TypeDeclaration getParentTypeDeclaration()
getParentTypeDeclaration in interface Memberpublic void setParentTypeDeclaration(TypeDeclaration dec)
setParentTypeDeclaration in interface Memberpublic 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