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
A block of code in curly braces in a class.
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.
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds 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.getChildBlock(int index) Returns the specified child block.intgetDeepestCodeBlockContaining(int offs) Returns the deepest code block nested under this one (or this one itself) containing a given offset.Returns the doc comment for this member.getLocalVar(int index) Returns the specified local variable.intgetLocalVarsBefore(int offs) Returns all local variables declared before a given offset, both in this code block and in all parent blocks.Returns the modifiers of this member.getType()Returnsnull, since blocks don't have types.booleanReturns whether this member is deprecated.booleanisStatic()Returns whether this block is a static block (in a class declaration).voidMethods inherited from class AbstractMember
getParentTypeDeclaration, setParentTypeDeclarationMethods inherited from class AbstractASTNode
getName, getNameEndOffset, getNameStartOffset, setDeclarationEndOffset, setDeclarationOffsets, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Member
getName, getNameEndOffset, getNameStartOffset
-
Field Details
-
NAME
-
parent
-
children
-
localVars
-
isStatic
private boolean isStatic
-
-
Constructor Details
-
CodeBlock
-
-
Method Details
-
add
Adds a child code block to this code block.- Parameters:
child- The child code block to add.- See Also:
-
addLocalVariable
Adds a local variable to this code block.- Parameters:
localVar- The local variable to add.- See Also:
-
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
Returns the specified child block.- Parameters:
index- The index of the child block.- Returns:
- The child block.
- See Also:
-
getChildBlockCount
public int getChildBlockCount() -
getDeepestCodeBlockContaining
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
-
getLocalVar
Returns the specified local variable.- Parameters:
index- The index of the variable.- Returns:
- The local variable.
- See Also:
-
getLocalVarCount
public int getLocalVarCount() -
getLocalVarsBefore
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
-
getParent
-
getType
-
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:
-
setParent
-