Class MethodTreeUtils
java.lang.Object
org.sonar.java.checks.helpers.MethodTreeUtils
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompareMainMethodPriority(MethodTree compared, MethodTree reference) Compares the priority of two main methods.static Optional<MethodInvocationTree> static booleanisGetterLike(Symbol.MethodSymbol methodSymbol) static booleanstatic booleanisMainMethod(MethodTree m, JavaVersion javaVersion) isSetterLike(Symbol.MethodSymbol methodSymbol) static booleanstatic VariableTreelamdaArgumentAt(LambdaExpressionTree lambdaExpressionTree, int argumentPosition) static MethodInvocationTreeparentMethodInvocationOfArgumentAtPos(ExpressionTree argumentCandidate, int expectedArgumentPosition) static Optional<MethodInvocationTree> subsequentMethodInvocation(Tree tree, MethodMatchers methodMatchers)
-
Method Details
-
isMainMethod
-
compareMainMethodPriority
Compares the priority of two main methods. In Java 25 and above, a main method with a String[] parameter has higher priority than a main method without parameters. In earlier versions of Java, only a main method with a String[] parameter is considered valid.- Parameters:
compared- : first main method to comparereference- : second main method to compare- Returns:
- 1 if m1 has higher priority, -1 if m2 has higher priority, 0 if both have the same priority
-
parentMethodInvocationOfArgumentAtPos
@Nullable public static MethodInvocationTree parentMethodInvocationOfArgumentAtPos(@Nullable ExpressionTree argumentCandidate, int expectedArgumentPosition) - Returns:
- null when: - argumentCandidate is null - the parent is not a method invocation (ignoring parent parentheses) - argumentCandidate is not at the expected argument position Otherwise, returns the parent method invocation.
-
lamdaArgumentAt
@Nullable public static VariableTree lamdaArgumentAt(@Nullable LambdaExpressionTree lambdaExpressionTree, int argumentPosition) -
isEqualsMethod
-
isHashCodeMethod
-
isSetterMethod
-
consecutiveMethodInvocation
-
subsequentMethodInvocation
public static Optional<MethodInvocationTree> subsequentMethodInvocation(Tree tree, MethodMatchers methodMatchers) -
isGetterLike
-
isSetterLike
-