mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Extract method from the whole body of duplicate method, move constants to parameters (IDEA-144957)
This commit is contained in:
@@ -127,9 +127,13 @@ public class CodeInsightUtil {
|
||||
}
|
||||
if (endOffset != element2.getTextRange().getEndOffset()) return PsiElement.EMPTY_ARRAY;
|
||||
|
||||
if (parent instanceof PsiCodeBlock && parent.getParent() instanceof PsiBlockStatement &&
|
||||
if (parent instanceof PsiCodeBlock &&
|
||||
element1 == ((PsiCodeBlock)parent).getLBrace() && element2 == ((PsiCodeBlock)parent).getRBrace()) {
|
||||
return new PsiElement[]{parent.getParent()};
|
||||
if (parent.getParent() instanceof PsiBlockStatement) {
|
||||
return new PsiElement[]{parent.getParent()};
|
||||
}
|
||||
PsiElement[] children = parent.getChildren();
|
||||
return getStatementsInRange(children, ((PsiCodeBlock)parent).getFirstBodyElement(), ((PsiCodeBlock)parent).getLastBodyElement());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -139,6 +143,11 @@ public class CodeInsightUtil {
|
||||
*/
|
||||
|
||||
PsiElement[] children = parent.getChildren();
|
||||
return getStatementsInRange(children, element1, element2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static PsiElement[] getStatementsInRange(PsiElement[] children, PsiElement element1, PsiElement element2) {
|
||||
ArrayList<PsiElement> array = new ArrayList<>();
|
||||
boolean flag = false;
|
||||
for (PsiElement child : children) {
|
||||
|
||||
Reference in New Issue
Block a user