mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
StreamApiMigration: add parentheses if necessary when .stream() can be omitted (fix for EA-93812).
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -447,7 +447,7 @@ class TerminalBlock {
|
||||
|
||||
String generate(boolean noStreamForEmpty) {
|
||||
if(noStreamForEmpty && myOperations.length == 1 && myOperations[0] instanceof CollectionStream) {
|
||||
return myOperations[0].getExpression().getText();
|
||||
return ParenthesesUtils.getText(myOperations[0].getExpression(), ParenthesesUtils.POSTFIX_PRECEDENCE);
|
||||
}
|
||||
return StreamEx.of(myOperations).map(Operation::createReplacement).joining();
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with forEach" "true"
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class Test {
|
||||
void test(Object obj) {
|
||||
((Collection<String>) obj).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with forEach" "true"
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class Test {
|
||||
void test(Object obj) {
|
||||
for(String str : (Collection<String>)<caret>obj) {
|
||||
System.out.println(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user