Package org.fife.rsta.ac.java.rjc.ast
Class CodeBlock
- java.lang.Object
-
- org.fife.rsta.ac.java.rjc.ast.AbstractASTNode
-
- org.fife.rsta.ac.java.rjc.ast.AbstractMember
-
- org.fife.rsta.ac.java.rjc.ast.CodeBlock
-
public class CodeBlock extends AbstractMember
A block of code in curly braces in a class.This class implements the
Memberinterface because a block can be a member (say, a static block in a class declaration), but usually it's not actually aMember, but something else, e.g. the body of a method, or the content of anif-statement, etc.- Version:
- 1.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(CodeBlock child)Adds a child code block to this code block.voidaddLocalVariable(LocalVariable localVar)Adds a local variable to this code block.booleancontainsOffset(int offs)Returns whether this code block contains the specified offset.CodeBlockgetChildBlock(int index)Returns the specified child block.intgetChildBlockCount()CodeBlockgetDeepestCodeBlockContaining(int offs)Returns the deepest code block nested under this one (or this one itself) containing a given offset.java.lang.StringgetDocComment()Returns the doc comment for this member.LocalVariablegetLocalVar(int index)Returns the specified local variable.intgetLocalVarCount()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.ModifiersgetModifiers()Returns the modifiers of this member.CodeBlockgetParent()TypegetType()Returnsnull, since blocks don't have types.booleanisDeprecated()Returns whether this member is deprecated.booleanisStatic()Returns whether this block is a static block (in a class declaration).voidsetParent(CodeBlock parent)-
Methods inherited from class org.fife.rsta.ac.java.rjc.ast.AbstractMember
getParentTypeDeclaration, setParentTypeDeclaration
-
Methods inherited from class org.fife.rsta.ac.java.rjc.ast.AbstractASTNode
getName, getNameEndOffset, getNameStartOffset, setDeclarationEndOffset, setDeclarationOffsets, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.fife.rsta.ac.java.rjc.ast.Member
getName, getNameEndOffset, getNameStartOffset
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
The name of allCodeBlocks.- See Also:
- Constant Field Values
-
parent
private CodeBlock parent
-
children
private java.util.List<CodeBlock> children
-
localVars
private java.util.List<LocalVariable> localVars
-
isStatic
private boolean isStatic
-
-
Constructor Detail
-
CodeBlock
public CodeBlock(boolean isStatic, Offset startOffs)
-
-
Method Detail
-
add
public void add(CodeBlock child)
Adds a child code block to this code block.- Parameters:
child- The child code block to add.- See Also:
getChildBlock(int)
-
addLocalVariable
public void addLocalVariable(LocalVariable localVar)
Adds a local variable to this code block.- Parameters:
localVar- The local variable to add.- See Also:
getLocalVar(int)
-
containsOffset
public boolean containsOffset(int offs)
Returns whether this code block contains the specified offset.- Parameters:
offs- The offset.- Returns:
- Whether this code block contains the offset.
-
getChildBlock
public CodeBlock getChildBlock(int index)
Returns the specified child block.- Parameters:
index- The index of the child block.- Returns:
- The child block.
- See Also:
getChildBlockCount()
-
getChildBlockCount
public int getChildBlockCount()
-
getDeepestCodeBlockContaining
public CodeBlock getDeepestCodeBlockContaining(int offs)
Returns the deepest code block nested under this one (or this one itself) containing a given offset.- Parameters:
offs- The offset to look for.- Returns:
- The deepest-nested code block containing the offset, or
nullif this code block and none of its children contain the offset.
-
getDocComment
public java.lang.String getDocComment()
Description copied from interface:MemberReturns the doc comment for this member.- Returns:
- This member's doc comment.
-
getLocalVar
public LocalVariable getLocalVar(int index)
Returns the specified local variable.- Parameters:
index- The index of the variable.- Returns:
- The local variable.
- See Also:
getLocalVarCount()
-
getLocalVarCount
public int getLocalVarCount()
-
getLocalVarsBefore
public 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.- Parameters:
offs- The offset.- Returns:
- The
LocalVariables, or an empty list of none were declared before the offset.
-
getModifiers
public Modifiers getModifiers()
Description copied from interface:MemberReturns the modifiers of this member.- Returns:
- The modifiers.
-
getParent
public CodeBlock getParent()
-
getType
public Type getType()
Returnsnull, since blocks don't have types.- Returns:
nullalways.
-
isDeprecated
public boolean isDeprecated()
Description copied from interface:MemberReturns whether this member is deprecated.- Returns:
- Whether this member is deprecated.
-
isStatic
public boolean isStatic()
Returns whether this block is a static block (in a class declaration).- Specified by:
isStaticin interfaceMember- Overrides:
isStaticin classAbstractMember- Returns:
- Whether this is a static code block.
- See Also:
Member.getModifiers()
-
setParent
public void setParent(CodeBlock parent)
-
-