mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
StreamToLoop: do not trim trailing whitespace for block lambdas
Fixes trailing line comment handling
This commit is contained in:
@@ -619,7 +619,9 @@ abstract class FunctionHelper {
|
||||
String getStatementText() {
|
||||
PsiElement[] children = myBody.getChildren();
|
||||
// Keep everything except braces
|
||||
return StreamEx.of(children, 1, children.length - 1).map(PsiElement::getText).joining().trim();
|
||||
return StreamEx.of(children, 1, children.length - 1)
|
||||
.dropWhile(e -> e instanceof PsiWhiteSpace)
|
||||
.map(PsiElement::getText).joining();
|
||||
}
|
||||
|
||||
void transform(StreamToLoopReplacementContext context, String... argumentValues) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
class X {
|
||||
|
||||
void x(File[] files) {
|
||||
for (File s: files) {
|
||||
File dest = new File(s.getAbsolutePath());
|
||||
System.out.println("unable to rename " + s + " to " + dest); //comment
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
class X {
|
||||
|
||||
void x(File[] files) {
|
||||
Arrays.stream(files).forEachOrdered(s -> {
|
||||
File dest = new File(s.getAbsolutePath());<caret>
|
||||
System.out.println("unable to rename " + s + " to " + dest); //comment
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user