mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
CodeEditUtil.addChildren: avoid returning invalid AST
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// "Remove 'if' statement extracting side effects" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
class X {
|
||||
public String getRole(Object parent) {
|
||||
if (parent instanceof Foo) {
|
||||
((Foo) parent).getBar();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
@NotNull
|
||||
Integer getBar();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Remove 'if' statement extracting side effects" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
class X {
|
||||
public String getRole(Object parent) {
|
||||
if (parent instan<caret>ceof Foo && ((Foo)parent).getBar() == null) {
|
||||
return "a";
|
||||
}
|
||||
else {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
@NotNull
|
||||
Integer getBar();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class CodeEditUtil {
|
||||
ASTNode result = first;
|
||||
if (firstAddedLeaf != null) {
|
||||
ASTNode placeHolderEnd = makePlaceHolderBetweenTokens(prevLeaf, firstAddedLeaf, isFormattingRequired(prevLeaf, first), false);
|
||||
if (placeHolderEnd != prevLeaf && first == firstAddedLeaf) {
|
||||
if (placeHolderEnd != prevLeaf && first == firstAddedLeaf || result.getTreeParent() != parent) {
|
||||
result = placeHolderEnd;
|
||||
}
|
||||
ASTNode lastAddedLeaf = findLastLeaf(first, last);
|
||||
|
||||
Reference in New Issue
Block a user