Class ASTLambdaExpression

java.lang.Object
net.sourceforge.pmd.lang.ast.impl.AbstractNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
net.sourceforge.pmd.lang.java.ast.ASTLambdaExpression
All Implemented Interfaces:
net.sourceforge.pmd.lang.ast.impl.GenericNode<JavaNode>, net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode<JavaNode>, net.sourceforge.pmd.lang.ast.Node, net.sourceforge.pmd.lang.ast.TextAvailableNode, ASTExpression, ASTMemberValue, ASTSwitchArrowRHS, FunctionalExpression, JavaNode, ReturnScopeNode, TypeNode, net.sourceforge.pmd.reporting.Reportable

public final class ASTLambdaExpression extends net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode> implements FunctionalExpression, ReturnScopeNode
A lambda expression.

 LambdaExpression ::= LambdaParameterList  "->" ( Expression | Block )

 
  • Field Details

  • Method Details

    • getTypeMirror

      public @NonNull JTypeMirror getTypeMirror()
      Returns the type of the functional interface. E.g. in stringStream.map(s -> s.isEmpty()), this is java.util.function.Function<java.lang.String, java.lang.Boolean>.
      Specified by:
      getTypeMirror in interface FunctionalExpression
      Specified by:
      getTypeMirror in interface TypeNode
      Returns:
      The type mirror. Never returns null; if the type is unresolved, returns TypeSystem.UNKNOWN.
      See Also:
    • getFunctionalMethod

      public JMethodSig getFunctionalMethod()
      Returns the method that is overridden in the functional interface. E.g. in stringStream.map(s -> s.isEmpty()), this is java.util.function.Function#apply(java.lang.String) -> java.lang.Boolean
      Specified by:
      getFunctionalMethod in interface FunctionalExpression
      See Also:
    • getParameters

      public ASTLambdaParameterList getParameters()
    • isExplicitlyTyped

      public boolean isExplicitlyTyped()
      Return true if this lambda is explicitly typed, meaning all parameters have an explicit type. Note that lambdas with zero parameters are explicitly typed.
    • isBlockBody

      public boolean isBlockBody()
      Returns true if this lambda has a block for body.
    • isExpressionBody

      public boolean isExpressionBody()
      Returns true if this lambda has an expression for body.
    • getBlock

      @Deprecated public @Nullable ASTBlock getBlock()
      Deprecated.
      Returns the body of this expression, if it is a block.
    • getExpression

      @Deprecated public @Nullable ASTExpression getExpression()
      Deprecated.
      Returns the body of this expression, if it is an expression.
    • getBlockBody

      public @Nullable ASTBlock getBlockBody()
      Returns the body of this lambda if it is a block.
    • getBody

      public @Nullable ASTBlock getBody()
      Returns the body of this lambda if it is a block.
      Specified by:
      getBody in interface ReturnScopeNode
    • getExpressionBody

      public @Nullable ASTExpression getExpressionBody()
      Returns the body of this lambda if it is an expression.
    • isFindBoundary

      public boolean isFindBoundary()
      Specified by:
      isFindBoundary in interface net.sourceforge.pmd.lang.ast.Node
    • getArity

      public int getArity()
      Returns the number of formal parameters of this lambda.
    • acceptVisitor

      protected <P, R> R acceptVisitor(JavaVisitor<? super P,? extends R> visitor, P data)
    • getParenthesisDepth

      public int getParenthesisDepth()
      Description copied from interface: ASTExpression
      Returns the number of parenthesis levels around this expression. If this method returns 0, then no parentheses are present.

      E.g. the expression (a + b) is parsed as an AdditiveExpression whose parenthesisDepth is 1, and in ((a + b)) it's 2.

      This is to avoid the parentheses interfering with analysis. Parentheses already influence parsing by breaking the natural precedence of operators. It would mostly hide false positives to make a ParenthesizedExpr node, because it would make semantically equivalent nodes have a very different representation.

      On the other hand, when a rule explicitly cares about parentheses, then this attribute may be used to find out whether parentheses were mentioned, so no information is lost.

      Specified by:
      getParenthesisDepth in interface ASTExpression
    • getConstFoldingResult

      public @NonNull ASTExpression.ConstResult getConstFoldingResult()
      Description copied from interface: ASTExpression
      Returns the result of constant folding on this expression. This may find a constant value for more than strict compile-time constants. See ASTExpression.ConstResult.
      Specified by:
      getConstFoldingResult in interface ASTExpression
    • buildConstValue

      @Deprecated protected @Nullable Object buildConstValue()
      Deprecated.
      Since 7.12.0. Kept for binary compatibility. This method should have been package-private from the start. Use ASTExpression.getConstValue() or ASTExpression.getConstFoldingResult() instead.
    • getTypeMirror

      public @NonNull JTypeMirror getTypeMirror(TypingContext context)
      Specified by:
      getTypeMirror in interface TypeNode
    • jjtClose

      public void jjtClose()
      Overrides:
      jjtClose in class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • acceptVisitor

      public final <P, R> R acceptVisitor(net.sourceforge.pmd.lang.ast.AstVisitor<? super P,? extends R> visitor, P data)
      Specified by:
      acceptVisitor in interface net.sourceforge.pmd.lang.ast.Node
    • addChild

      protected void addChild(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child, int index)
      Overrides:
      addChild in class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • insertChild

      protected void insertChild(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child, int index)
      Overrides:
      insertChild in class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • removeChildAtIndex

      protected void removeChildAtIndex(int childIndex)
      Overrides:
      removeChildAtIndex in class net.sourceforge.pmd.lang.ast.impl.AbstractNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setImage

      protected void setImage(String image)
      Overrides:
      setImage in class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setFirstToken

      protected void setFirstToken(net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken token)
      Overrides:
      setFirstToken in class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setLastToken

      protected void setLastToken(net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken token)
      Overrides:
      setLastToken in class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • enlargeLeft

      protected void enlargeLeft(net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken child)
      Overrides:
      enlargeLeft in class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • setChild

      protected void setChild(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child, int index)
      Overrides:
      setChild in class net.sourceforge.pmd.lang.ast.impl.AbstractNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,JavaNode>
    • getSymbolTable

      public @NonNull JSymbolTable getSymbolTable()
      Description copied from interface: JavaNode
      Returns the symbol table for the program point represented by this node.
      Specified by:
      getSymbolTable in interface JavaNode
    • getTypeSystem

      public TypeSystem getTypeSystem()
      Description copied from interface: JavaNode
      Returns the type system with which this node was created. This is the object responsible for representing types in the compilation unit.
      Specified by:
      getTypeSystem in interface JavaNode
    • getRoot

      public final @NonNull ASTCompilationUnit getRoot()
      Specified by:
      getRoot in interface JavaNode
      Specified by:
      getRoot in interface net.sourceforge.pmd.lang.ast.Node
    • getXPathNodeName

      public final String getXPathNodeName()
      Specified by:
      getXPathNodeName in interface net.sourceforge.pmd.lang.ast.Node