Class ASTExpression
- java.lang.Object
-
- net.sourceforge.pmd.lang.ast.impl.AbstractNode<B,N>
-
- net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.visualforce.ast.AbstractVfNode,VfNode>
-
- net.sourceforge.pmd.lang.visualforce.ast.ASTExpression
-
- All Implemented Interfaces:
GenericNode<VfNode>
,JjtreeNode<VfNode>
,Node
,TextAvailableNode
,VfNode
,Reportable
public final class ASTExpression extends AbstractJjtreeNode<net.sourceforge.pmd.lang.visualforce.ast.AbstractVfNode,VfNode>
-
-
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.ast.impl.javacc.AbstractJjtreeNode
id
-
Fields inherited from interface net.sourceforge.pmd.lang.ast.Node
COORDS_COMPARATOR
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <P,R>
RacceptVfVisitor(VfVisitor<? super P,? extends R> visitor, P data)
<P,R>
RacceptVisitor(AstVisitor<? super P,? extends R> visitor, P data)
Map<VfTypedNode,String>
getDataNodes()
An Expression can contain one or more strings that map to a piece of data.String
getXPathNodeName()
protected void
setImage(String image)
-
Methods inherited from class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode
addChild, compareLocation, fitTokensToChildren, getFirstToken, getImage, getLastToken, getTextRegion, insertChild, jjtClose, jjtOpen, setFirstToken, setLastToken, toString
-
Methods inherited from class net.sourceforge.pmd.lang.ast.impl.AbstractNode
children, firstChild, getChild, getIndexInParent, getNumChildren, getParent, getUserMap, remove, removeChildAtIndex, setChild, setParent
-
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.impl.GenericNode
ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getParent, getPreviousSibling
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode
getFirstToken, getLastToken, tokens
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
ancestors, children, compareLocation, descendants, firstChild, getAstInfo, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getImage, getIndexInParent, getLanguageVersion, getNumChildren, getReportLocation, getRoot, getTextDocument, getUserMap, getXPathAttributesIterator, hasImageEqualTo, isFindBoundary
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.TextAvailableNode
getOriginalText, getText, getTextRegion
-
-
-
-
Method Detail
-
acceptVfVisitor
protected <P,R> R acceptVfVisitor(VfVisitor<? super P,? extends R> visitor, P data)
-
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.
-
setImage
protected void setImage(String image)
- Overrides:
setImage
in classAbstractJjtreeNode<net.sourceforge.pmd.lang.visualforce.ast.AbstractVfNode,VfNode>
-
getXPathNodeName
public String getXPathNodeName()
- Specified by:
getXPathNodeName
in interfaceNode
-
acceptVisitor
public final <P,R> R acceptVisitor(AstVisitor<? super P,? extends R> visitor, P data)
- Specified by:
acceptVisitor
in interfaceNode
-
-