diff --git a/java/java-impl-inspections/src/com/intellij/codeInspection/RedundantStreamOptionalCallInspection.java b/java/java-impl-inspections/src/com/intellij/codeInspection/RedundantStreamOptionalCallInspection.java index de22378e8643..bbafa9e24b7d 100644 --- a/java/java-impl-inspections/src/com/intellij/codeInspection/RedundantStreamOptionalCallInspection.java +++ b/java/java-impl-inspections/src/com/intellij/codeInspection/RedundantStreamOptionalCallInspection.java @@ -45,7 +45,7 @@ public class RedundantStreamOptionalCallInspection extends AbstractBaseJavaLocal private static final Map CALLS_MAKING_SORT_USELESS_PARALLEL = Map.of("findAny", "findFirst", "forEach", "forEachOrdered"); private static final Set CALLS_KEEPING_SORT_ORDER = - Set.of("filter", "distinct", "boxed", "asLongStream", "asDoubleStream", "takeWhile", "dropWhile"); + Set.of("filter", "distinct", "boxed", "asLongStream", "asDoubleStream"); private static final Set CALLS_KEEPING_ELEMENTS_DISTINCT = Set.of("filter", "boxed", "asLongStream", "limit", "skip", "sorted", "takeWhile", "dropWhile"); private static final Set CALLS_AFFECTING_PARALLELIZATION = Set.of("sequential", "parallel"); diff --git a/java/java-tests/testData/inspection/redundantStreamOptionalCall/RedundantStreamOptionalCall.java b/java/java-tests/testData/inspection/redundantStreamOptionalCall/RedundantStreamOptionalCall.java index a08c5626d970..d4ee9396081e 100644 --- a/java/java-tests/testData/inspection/redundantStreamOptionalCall/RedundantStreamOptionalCall.java +++ b/java/java-tests/testData/inspection/redundantStreamOptionalCall/RedundantStreamOptionalCall.java @@ -89,6 +89,14 @@ public class RedundantStreamOptionalCall { // another stream c.parallelStream().sorted().findFirst().get().chars().parallel().forEach(System.out::println); } + + void dropWhileAndSort() { + List collect = Stream.of("E", "D", "C", "B") + .sorted() + .dropWhile(x -> !x.equals("D")) + .sorted(Comparator.reverseOrder()) + .collect(Collectors.toList()); + } void parallelSorted(Collection c) { c.stream().sorted().forEach(x -> {}); diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantStreamOptionalCallInspectionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantStreamOptionalCallInspectionTest.java index 01168b5278f4..19436ac0aa8f 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantStreamOptionalCallInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantStreamOptionalCallInspectionTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.codeInspection; import com.intellij.JavaTestUtil; @@ -44,7 +30,7 @@ public class RedundantStreamOptionalCallInspectionTest extends LightJavaInspecti @NotNull @Override protected LightProjectDescriptor getProjectDescriptor() { - return JAVA_8; + return JAVA_17; } public static class RedundantStreamOptionalCallFixTest extends LightQuickFixParameterizedTestCase {