File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
java-checks/src/main/java/org/sonar/java/checks Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 1616 */
1717package org .sonar .java .checks ;
1818
19+ import java .util .Arrays ;
1920import java .util .Collections ;
2021import java .util .List ;
22+ import java .util .stream .Stream ;
2123import javax .annotation .CheckForNull ;
2224import javax .annotation .Nullable ;
2325import org .sonar .check .Rule ;
5456@ Rule (key = "S2293" )
5557public class DiamondOperatorCheck extends SubscriptionVisitor implements JavaVersionAwareVisitor {
5658
59+ /** Nodes to check in Java 7. */
5760 private static final Tree .Kind [] JAVA_7_KINDS = new Tree .Kind [] {
5861 Tree .Kind .VARIABLE ,
5962 Tree .Kind .TYPE_CAST ,
6063 Tree .Kind .RETURN_STATEMENT ,
6164 Tree .Kind .ASSIGNMENT
6265 };
6366
64- private static final Tree .Kind [] JAVA_8_KINDS = new Tree .Kind [] {
65- Tree .Kind .VARIABLE ,
66- Tree .Kind .TYPE_CAST ,
67- Tree .Kind .RETURN_STATEMENT ,
68- Tree .Kind .ASSIGNMENT ,
69- Tree .Kind .CONDITIONAL_EXPRESSION
70- };
67+ /** Nodes to check in Java 8 and up. */
68+ private static final Tree .Kind [] JAVA_8_KINDS =
69+ Stream .concat (
70+ Arrays .stream (JAVA_7_KINDS ),
71+ Stream .of (Tree .Kind .CONDITIONAL_EXPRESSION )
72+ ).toArray (Tree .Kind []::new );
7173
7274 private Tree .Kind [] expressionKindsToCheck = JAVA_7_KINDS ;
7375
You can’t perform that action at this time.
0 commit comments