Package org.sonar.java.model
Class ExpressionUtils
- java.lang.Object
-
- org.sonar.java.model.ExpressionUtils
-
public final class ExpressionUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IdentifierTree
extractIdentifier(AssignmentExpressionTree tree)
static MethodTree
getEnclosingMethod(ExpressionTree expr)
static boolean
isNullLiteral(ExpressionTree tree)
static boolean
isSecuringByte(ExpressionTree expression)
static boolean
isSelectOnThisOrSuper(AssignmentExpressionTree tree)
static boolean
isSelectOnThisOrSuper(MemberSelectExpressionTree tree)
Checks of is the given tree is selecting withthis
orsuper
static boolean
isSimpleAssignment(AssignmentExpressionTree tree)
In case of simple assignments, only the expression is evaluated, as we only use the reference to the variable to store the result.static IdentifierTree
methodName(MethodInvocationTree mit)
Retrieve the identifier corresponding to the method name associated to the method invocationstatic ExpressionTree
skipParentheses(ExpressionTree tree)
-
-
-
Method Detail
-
isSimpleAssignment
public static boolean isSimpleAssignment(AssignmentExpressionTree tree)
In case of simple assignments, only the expression is evaluated, as we only use the reference to the variable to store the result. For SE-Based checks, only a single value should be unstacked if its the case. For other cases, two values should be unstacked. See JLS8-15.26- Parameters:
tree
- The assignment tree- Returns:
- true if the tree is a simple assignment
- See Also:
extractIdentifier(AssignmentExpressionTree)
-
isSelectOnThisOrSuper
public static boolean isSelectOnThisOrSuper(AssignmentExpressionTree tree)
- Parameters:
tree
- The tree to check.- Returns:
- true when the tree is a select on
this
orsuper
- See Also:
isSelectOnThisOrSuper(MemberSelectExpressionTree)
-
isSelectOnThisOrSuper
public static boolean isSelectOnThisOrSuper(MemberSelectExpressionTree tree)
Checks of is the given tree is selecting withthis
orsuper
- Parameters:
tree
- The tree to check.- Returns:
- true when the tree is a select on
this
orsuper
- See Also:
isSelectOnThisOrSuper(AssignmentExpressionTree)
-
extractIdentifier
public static IdentifierTree extractIdentifier(AssignmentExpressionTree tree)
-
skipParentheses
public static ExpressionTree skipParentheses(ExpressionTree tree)
-
isNullLiteral
public static boolean isNullLiteral(ExpressionTree tree)
-
isSecuringByte
public static boolean isSecuringByte(ExpressionTree expression)
-
methodName
public static IdentifierTree methodName(MethodInvocationTree mit)
Retrieve the identifier corresponding to the method name associated to the method invocation
-
getEnclosingMethod
@CheckForNull public static MethodTree getEnclosingMethod(ExpressionTree expr)
-
-