Package net.sourceforge.pmd.lang.vf.ast
Class ASTExpression
- java.lang.Object
-
- net.sourceforge.pmd.lang.ast.AbstractNode
-
- net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<VfNode>
-
- net.sourceforge.pmd.lang.vf.ast.AbstractVFNode
-
- net.sourceforge.pmd.lang.vf.ast.ASTExpression
-
public class ASTExpression extends AbstractVFNode
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ASTExpression.DataNodeStateException
Thrown in cases where the the Identifiers in this node aren't ALL successfully parsed in a call togetDataNodes()
-
Field Summary
-
Fields inherited from class net.sourceforge.pmd.lang.vf.ast.AbstractVFNode
parser
-
Fields inherited from class net.sourceforge.pmd.lang.ast.AbstractNode
beginColumn, beginLine, childIndex, children, endColumn, endLine, firstToken, id, lastToken, parent
-
-
Constructor Summary
Constructors Constructor Description ASTExpression(int id)
Deprecated.ASTExpression(VfParser p, int id)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<VfTypedNode,String>
getDataNodes()
An Expression can contain one or more strings that map to a piece of data.Object
jjtAccept(VfParserVisitor visitor, Object data)
Accept the visitor.-
Methods inherited from class net.sourceforge.pmd.lang.vf.ast.AbstractVFNode
childrenAccept, getXPathNodeName, jjtClose, jjtOpen
-
Methods inherited from class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode
children, getChild, getParent
-
Methods inherited from class net.sourceforge.pmd.lang.ast.AbstractNode
appendElement, findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, findDescendantsOfType, getAsDocument, getBeginColumn, getBeginLine, getDataFlowNode, getEndColumn, getEndLine, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfAnyType, getFirstParentOfType, getImage, getIndexInParent, getNthParent, getNumChildren, getParentsOfType, getUserData, getUserMap, getXPathAttributesIterator, hasDecendantOfAnyType, hasDescendantMatchingXPath, hasDescendantOfAnyType, hasDescendantOfType, hasImageEqualTo, isFindBoundary, isSingleLine, jjtAddChild, jjtGetChild, jjtGetChildIndex, jjtGetFirstToken, jjtGetId, jjtGetLastToken, jjtGetNumChildren, jjtGetParent, jjtSetChildIndex, jjtSetFirstToken, jjtSetLastToken, jjtSetParent, remove, removeChildAtIndex, setDataFlowNode, setImage, setUserData, testingOnlySetBeginColumn, testingOnlySetBeginLine, testingOnlySetEndColumn, testingOnlySetEndLine, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, findDescendantsOfType, getAsDocument, getBeginColumn, getBeginLine, getDataFlowNode, getEndColumn, getEndLine, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfAnyType, getFirstParentOfType, getImage, getIndexInParent, getNthParent, getNumChildren, getParentsOfType, getUserData, getUserMap, getXPathAttributesIterator, hasDescendantMatchingXPath, hasDescendantOfType, hasImageEqualTo, isFindBoundary, jjtAddChild, jjtGetChild, jjtGetChildIndex, jjtGetId, jjtGetNumChildren, jjtGetParent, jjtSetChildIndex, jjtSetParent, remove, removeChildAtIndex, setDataFlowNode, setImage, setUserData
-
-
-
-
Constructor Detail
-
ASTExpression
@Deprecated @InternalApi public ASTExpression(int id)
Deprecated.
-
ASTExpression
@Deprecated @InternalApi public ASTExpression(VfParser p, int id)
Deprecated.
-
-
Method Detail
-
jjtAccept
public Object jjtAccept(VfParserVisitor visitor, Object data)
Description copied from class:AbstractVFNode
Accept the visitor. *- Specified by:
jjtAccept
in interfaceVfNode
- Overrides:
jjtAccept
in classAbstractVFNode
-
getDataNodes
public Map<VfTypedNode,String> getDataNodes() throws ASTExpression.DataNodeStateException
An Expression can contain one or more strings that map to a piece of data. This method maps the string from the Visualforce page to terminal AST node that the string represents. The terminal node will be either an ASTIdentifier or ASTLiteral. It is the terminal node that is most important since it represents the type of data that will be displayed in the page.
The string representation can be reconstructed by starting at the
Identifier
node and traversing its siblings until a node other than aDotExpression
is encountered. Some more advanced situations aren't currently handled by this method. The method will throw an exception in such cases.<apex:outputText value="{!MyValue}" /> results in AST <Identifier Image='MyValue'/> The method would return key=ASTIdentifier(Image='MyValue'), value="MyValue"
THE FOLLOWING SITUATIONS ARE NOT HANDLED AND WILL THROW AN EXCEPTION. This syntax causes ambiguities with Apex Controller methods that return Maps versus accessing a CustomObject's field via array notation. This may be addressed in a future release.<apex:outputText value="{!MyObject__c.Text__c}" /> results in AST (It's important to notice that DotExpression is a sibling of Identifier. <Identifier Image='MyObject__c'/> <DotExpression Image=''> <Identifier Image='Text__c'/> </DotExpression> This method would return key=ASTIdentifier(Image='Text__c'), value="MyObject__c.Text__c"
<apex:outputText value="{!MyObject__c['Text__c']}" /> results in AST <Identifier Image='MyObject__c'/> <Expression Image=''> <Literal Image=''Text__c''> </Expression> <apex:outputText value="{!MyObject__c[AnotherObject__c.Id]}" /> results in AST <Identifier Image='MyObject__c'/> <Expression Image=''> <Identifier Image='AnotherObject__c'/> <DotExpression Image=''> <Identifier Image='Id'/> </DotExpression> </Identifier> </Expression>
- Throws:
ASTExpression.DataNodeStateException
- if the results of this method could have been incorrect. Callers should typically not rethrow this exception, as it will happen often and doesn't represent a terminal exception.
-
-