mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
TerminalBlock: preserve comments after continue statement (not in the proper place though)
This commit is contained in:
@@ -253,7 +253,7 @@ class TerminalBlock {
|
||||
FilterOp filter = tb.getLastOperation(FilterOp.class);
|
||||
if (filter == null) return this;
|
||||
PsiBinaryExpression binOp = tryCast(PsiUtil.skipParenthesizedExprDown(filter.getExpression()), PsiBinaryExpression.class);
|
||||
if (binOp == null || !ComparisonUtils.isComparison(binOp)) return this;
|
||||
if (!ComparisonUtils.isComparison(binOp)) return this;
|
||||
String comparison = filter.isNegated() ? ComparisonUtils.getNegatedComparison(binOp.getOperationTokenType())
|
||||
: binOp.getOperationSign().getText();
|
||||
boolean flipped = false;
|
||||
@@ -477,7 +477,7 @@ class TerminalBlock {
|
||||
}
|
||||
StreamEx.ofTree(statement, (PsiElement s) -> StreamEx.of(s.getChildren()))
|
||||
.select(PsiContinueStatement.class)
|
||||
.forEach(stmt -> stmt.replace(factory.createStatementFromText("return;", null)));
|
||||
.forEach(stmt -> new CommentTracker().replaceAndRestoreComments(stmt, "return;"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ import java.util.Collection;
|
||||
|
||||
public class Test {
|
||||
void test(int[] arr) {
|
||||
// comment
|
||||
Arrays.stream(arr).forEach(x -> {
|
||||
int y = x * 2;
|
||||
if (x > y) return;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ public class Test {
|
||||
void test(int[] arr) {
|
||||
for<caret>(int x : arr) {
|
||||
int y = x*2;
|
||||
if(x > y) continue;
|
||||
if(x > y) continue; // comment
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user