mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SortContentAction: fix \n placement in presence of comments: IDEA-199734
This commit is contained in:
@@ -658,7 +658,10 @@ public class SortContentAction extends PsiElementBaseIntentionAction {
|
||||
@Override
|
||||
String generateReplacementText(@NotNull SortableList list, @NotNull PsiArrayInitializerMemberValue elementToSort) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
list.generate(sb);
|
||||
boolean newLineRequired = list.generate(sb);
|
||||
if (newLineRequired) {
|
||||
sb.append("\n");
|
||||
}
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -795,11 +798,8 @@ public class SortContentAction extends PsiElementBaseIntentionAction {
|
||||
sb.append(child.getText());
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
sortableList.generate(sb);
|
||||
|
||||
List<SortableEntry> entries = sortableList.myEntries;
|
||||
SortableEntry last = entries.get(entries.size() - 1);
|
||||
if (!last.myBeforeSeparator.isEmpty()) {
|
||||
boolean newLineRequired = sortableList.generate(sb);
|
||||
if (newLineRequired) {
|
||||
sb.append("\n");
|
||||
}
|
||||
sb.append(")");
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Sort content" "true"
|
||||
|
||||
class X {
|
||||
public void x() {
|
||||
doTest("1 ",
|
||||
"T", "and", "between", "div", "eq", "false", "ge", "gt",
|
||||
"instanceof", "le", "lt", "matches", "mod", "ne", "new", "not", "null", "or",
|
||||
"true" //comment
|
||||
);
|
||||
}
|
||||
|
||||
private void doTest(String... s) {
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -16,7 +16,6 @@ public class Main {
|
||||
"foo" /*3*/ // 2
|
||||
// 5
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Sort content" "true"
|
||||
|
||||
class X {
|
||||
public void x() {
|
||||
doTest("1 <caret>",
|
||||
"and", "between", "div", "eq", "false", "ge", "gt", "instanceof",
|
||||
"le", "lt", "matches", "mod", "ne", "new", "not", "null", "or", "true", //comment
|
||||
"T");
|
||||
}
|
||||
|
||||
private void doTest(String... s) {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user