public class FunctionNode extends BaseTypedDefinitionNode implements IFunctionNode
Modifier and Type | Field and Description |
---|---|
protected IFunctionContentsPart |
contentsPart
Contents of the function, including args, etc
|
typeNode, typeOperatorStart
definition, nameNode
emptyNodeArray, parent
UNKNOWN
Constructor and Description |
---|
FunctionNode(IASToken functionKeyword,
IdentifierNode nameNode)
Constructor.
|
FunctionNode(IdentifierNode node,
IFunctionContentsPart part)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
analyze(EnumSet<PostProcessStep> set,
ASScope scope,
Collection<ICompilerProblem> problems) |
protected boolean |
buildInnerString(StringBuilder sb)
For debugging only.
|
boolean |
containsLocalFunctions()
Does this function have a local functions within
|
protected IFunctionContentsPart |
createContentsPart() |
protected FunctionDefinition |
createFunctionDefinition(String name)
Method to create the correct Definition class - needed so we can create
different Definition types for getters, setters, and plain old functions
|
void |
discardFunctionBody()
Delete all children nodes in a function body.
|
INamespaceDecorationNode |
getActualNamespaceNode()
Get the real namespace node, or null if there isn't one.
|
FunctionDefinition |
getDefinition() |
boolean |
getEmittingLocalFunctions()
flag to determine whether to emit the local function
or a reference to it
|
IFunctionDefinition.FunctionClassification |
getFunctionClassification()
Get the classification for this function (local, argument, class member,
etc)
|
KeywordNode |
getFunctionKeywordNode()
Get the function keyword
|
protected int |
getInitialChildCount()
Take a guess as to an efficient initial child count.
|
List<IFunctionNode> |
getLocalFunctions()
Get local functions within
|
String |
getNamespace()
Returns the namespace that this member belongs to
|
INamespaceDecorationNode |
getNamespaceNode() |
ASTNodeID |
getNodeID()
Get the opcode of this node
|
IParameterNode[] |
getParameterNodes()
Get the parameters of this function as an array of
IParameterNode
elements |
ContainerNode |
getParametersContainerNode()
Returns the container for parameters of this function
|
Collection<ICompilerProblem> |
getParsingProblems()
Get any saved parsing problems from lazily parsing the function body.
|
String |
getQualifiedName()
Get the qualified name of this type
|
String |
getReturnType()
Returns the type of this function as it exist in source.
|
IExpressionNode |
getReturnTypeNode()
Returns the
IExpressionNode that corresponds to the return type
node of this IFunctionNode |
ScopedBlockNode |
getScopedNode()
Returns the scope that is contained with this definition.
|
String |
getShortName()
Get the short name of this type (without any package information)
|
int |
getSpanningStart()
Gets the local offset where the node starts, including any extra items that may
change the appearance of the node's start.
|
boolean |
hasBeenParsed() |
boolean |
hasBody()
Does this function have a non-empty body
|
boolean |
hasNamespace(String namespace)
Is the given namespace present on this definition?
|
protected void |
init(ExpressionNodeBase idNode) |
boolean |
isCastFunction()
Is this a cast function?
|
boolean |
isConstructor()
Is this a constructor?
|
boolean |
isConstructorOf(ClassNode classNode)
Is this a constructor of the specified class (assumes that this function
definition is actually located in the body of the specified class)
|
boolean |
isGetter()
Is this function a getter?
|
boolean |
isImplicit()
Is this definition an implicit definition that doesn't actually appear in
the source file?
|
boolean |
isPackageLevelFunction()
Determine whether this is a package-level function (i.e. a function
defined in a package, as opposed to a class or some other scope)
|
boolean |
isSetter()
Is this function a setter?
|
void |
normalize(boolean fillInOffsets)
Normalize the tree.
|
void |
parseFunctionBody(Collection<ICompilerProblem> problems)
Build AST for the function body from the buffered function body text.
|
void |
rememberLocalFunction(IFunctionNode value)
Remember local Functions in this function node().
|
protected void |
setChildren(boolean fillInOffsets)
If this node has custom children (names, arguments, etc), shove them into
the list of children.
|
protected void |
setDefinition(IDefinition def) |
void |
setEmittingLocalFunctions(boolean emit)
flag to determine whether to emit the local function
or a reference to it
|
void |
setFunctionBodyInfo(ASToken openT,
ASToken lastTokenInBody,
ConfigProcessor configProcessor,
StringBuilder bodyCache)
Store the function body text on the function node so that the AST nodes
can be rebuilt later.
|
buildBindableGetter, buildBindableSetter, fillinDefinition, getTypeName, getTypeNode, getTypeOperatorEnd, getTypeOperatorStart, hasExplicitType, hasTypeOperator, isAnyType, isVoidType, setType
addDecorationChildren, addModifier, createDecorationPart, fillInMetadata, fillInModifiers, fillInNamespaceAndModifiers, getASDocComment, getDecorationPart, getMetaInfos, getMetaTags, getMetaTagsNode, getModifiers, getModifiersContainer, getName, getNameAbsoluteEnd, getNameAbsoluteStart, getNameEnd, getNameExpressionNode, getNameStart, getNodeStartForTooling, hasExplicitComment, hasModifier, setASDocComment, setMetaTags, setModifiersContainer, setNamespace
addChild, addChild, addChildInOrder, addChildPostNormalize, addTemporaryChild, getChild, getChildCount, optimizeChildren, removeAllChildren, removeChild, removeTemporaryChild, replaceChild, sortChildren, swapChildren
buildStringRecursive, canContinueContainmentSearch, collectImportNodes, combineAttributes, connectedToProjectScope, contains, endAfter, endAfter, endBefore, endBefore, fillInOffsets, getAbsoluteEnd, getAbsoluteStart, getAncestorOfType, getASScope, getContainingFilePath, getContainingNode, getContainingScope, getEnd, getFileScope, getFileSpecification, getInnerString, getNodeKind, getPackageName, getParent, getScopeNode, getStart, getSucceedingNode, getWorkspace, isTerminal, isTransparent, looselyContains, runPostProcess, setParent, span, span, span, startAfter, startAfter, startBefore, startBefore, toString, tryGetOffsetLookup, verify
getColumn, getEndColumn, getEndLine, getLine, getLineColumnString, getOffsetsString, getSourcePath, getSourcePathString, setColumn, setEnd, setEndColumn, setEndLine, setLine, setSourceLocation, setSourcePath, setStart, span, span
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getASDocComment, hasExplicitComment
getContainingFilePath, getMetaInfos, getMetaTags, getName, getNameAbsoluteEnd, getNameAbsoluteStart, getNameEnd, getNameExpressionNode, getNameStart, getPackageName, hasModifier
contains, getAncestorOfType, getChild, getChildCount, getContainingNode, getContainingScope, getFileSpecification, getParent, getSucceedingNode, isTerminal
getAbsoluteEnd, getAbsoluteStart, getColumn, getEnd, getEndColumn, getEndLine, getLine, getSourcePath, getStart
protected IFunctionContentsPart contentsPart
public FunctionNode(IASToken functionKeyword, IdentifierNode nameNode)
Creates a FunctionNode
from the "new" keyword token and the
function name node.
functionKeyword
- function keywordnameNode
- node containing the name of this functionpublic FunctionNode(IdentifierNode node, IFunctionContentsPart part)
Creates a new FunctionNode with a custom part for this functions contents.
node
- the name of the nodepart
- the IFunctionContentsPart
public ASTNodeID getNodeID()
IASNode
public int getSpanningStart()
IASNode
getSpanningStart
in interface IASNode
getSpanningStart
in class BaseDefinitionNode
protected void setChildren(boolean fillInOffsets)
NodeBase
setChildren
in class NodeBase
public void normalize(boolean fillInOffsets)
NodeBase
normalize
in class BaseDefinitionNode
protected void analyze(EnumSet<PostProcessStep> set, ASScope scope, Collection<ICompilerProblem> problems)
analyze
in class BaseDefinitionNode
protected boolean buildInnerString(StringBuilder sb)
NodeBase
buildOuterString()
.
It is overridden by subclasses to display optional node-specific
information in the middle of the string, between the node type and the
location information.buildInnerString
in class NodeBase
protected int getInitialChildCount()
TreeNode
getInitialChildCount
in class TreeNode
protected void init(ExpressionNodeBase idNode)
init
in class BaseTypedDefinitionNode
public INamespaceDecorationNode getNamespaceNode()
getNamespaceNode
in class BaseDefinitionNode
public String getNamespace()
IDefinitionNode
getNamespace
in interface IDefinitionNode
getNamespace
in class BaseDefinitionNode
public boolean hasNamespace(String namespace)
IDefinitionNode
hasNamespace
in interface IDefinitionNode
hasNamespace
in class BaseDefinitionNode
namespace
- the namespace to check forpublic FunctionDefinition getDefinition()
getDefinition
in interface IDefinitionNode
getDefinition
in interface IFunctionNode
getDefinition
in class BaseDefinitionNode
protected void setDefinition(IDefinition def)
setDefinition
in class BaseDefinitionNode
public boolean isImplicit()
IDefinitionNode
this
, super
,
default constructors, and cast functions.isImplicit
in interface IDefinitionNode
public String getQualifiedName()
IDefinitionNode
getQualifiedName
in interface IDefinitionNode
public String getShortName()
IDefinitionNode
getShortName
in interface IDefinitionNode
public final ScopedBlockNode getScopedNode()
IScopedDefinitionNode
getScopedNode
in interface IScopedDefinitionNode
IDefinitionNode
public IFunctionDefinition.FunctionClassification getFunctionClassification()
IFunctionNode
getFunctionClassification
in interface IFunctionNode
public boolean isGetter()
IFunctionNode
isGetter
in interface IFunctionNode
public boolean isSetter()
IFunctionNode
isSetter
in interface IFunctionNode
public boolean isConstructor()
IFunctionNode
isConstructor
in interface IFunctionNode
public boolean isCastFunction()
IFunctionNode
isCastFunction
in interface IFunctionNode
public ContainerNode getParametersContainerNode()
IFunctionNode
getParametersContainerNode
in interface IFunctionNode
public IParameterNode[] getParameterNodes()
IFunctionNode
IParameterNode
elementsgetParameterNodes
in interface IFunctionNode
public IExpressionNode getReturnTypeNode()
IFunctionNode
IExpressionNode
that corresponds to the return type
node of this IFunctionNode
getReturnTypeNode
in interface IFunctionNode
IExpressionNode
or nullpublic String getReturnType()
IFunctionNode
void
is returnedgetReturnType
in interface IFunctionNode
public boolean hasBody()
IFunctionNode
hasBody
in interface IFunctionNode
protected IFunctionContentsPart createContentsPart()
protected FunctionDefinition createFunctionDefinition(String name)
public KeywordNode getFunctionKeywordNode()
public boolean isPackageLevelFunction()
public INamespaceDecorationNode getActualNamespaceNode()
public boolean isConstructorOf(ClassNode classNode)
public Collection<ICompilerProblem> getParsingProblems()
public final void parseFunctionBody(Collection<ICompilerProblem> problems)
Make sure PostProcessStep.POPULATE_SCOPE
has been applied to the
containing FileNode
This method always populate scopes of the
rebuilt function node. If the scopes for the containing nodes weren't
initialized, the rebuilt scopes can attach itself to it's parent.
public final void discardFunctionBody()
public final boolean hasBeenParsed()
public final void setFunctionBodyInfo(ASToken openT, ASToken lastTokenInBody, ConfigProcessor configProcessor, StringBuilder bodyCache)
public List<IFunctionNode> getLocalFunctions()
IFunctionNode
getLocalFunctions
in interface IFunctionNode
public boolean containsLocalFunctions()
IFunctionNode
containsLocalFunctions
in interface IFunctionNode
public void rememberLocalFunction(IFunctionNode value)
IFunctionNode
rememberLocalFunction
in interface IFunctionNode
public boolean getEmittingLocalFunctions()
IFunctionNode
getEmittingLocalFunctions
in interface IFunctionNode
public void setEmittingLocalFunctions(boolean emit)
IFunctionNode
setEmittingLocalFunctions
in interface IFunctionNode
Copyright © 2016 The Apache Software Foundation. All rights reserved.