mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[extract method] IDEA-317497: search static context until target class only
GitOrigin-RevId: 1e5c8e3319a9a45506e0785d4e7912d71f0233c6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
57627111cc
commit
26bae9e549
+1
-1
@@ -125,7 +125,7 @@ object ExtractMethodPipeline {
|
||||
if (statement != null && JavaHighlightUtil.isSuperOrThisCall(statement, true, true)) {
|
||||
return extractOptions.copy(isStatic = true)
|
||||
}
|
||||
val shouldBeStatic = PsiUtil.getEnclosingStaticElement(extractOptions.elements.first(), null) != null
|
||||
val shouldBeStatic = PsiUtil.getEnclosingStaticElement(extractOptions.elements.first(), extractOptions.targetClass) != null
|
||||
return extractOptions.copy(isStatic = shouldBeStatic)
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Test<T> {
|
||||
|
||||
static class Inner<I extends Integer, T>{
|
||||
public void get(List<T> list, I i) {
|
||||
<selection>list.get(i);</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Test<T> {
|
||||
|
||||
static class Inner<I extends Integer, T>{
|
||||
public void get(List<T> list, I i) {
|
||||
extracted(list, i);
|
||||
}
|
||||
|
||||
private void extracted(List<T> list, I i) {
|
||||
list.get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Test<T> {
|
||||
|
||||
static class Inner<I extends Integer, T>{
|
||||
public void get(List<T> list, I i) {
|
||||
<selection>list.get(i);</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Test<T> {
|
||||
|
||||
static class Inner<I extends Integer, T>{
|
||||
public void get(List<T> list, I i) {
|
||||
extracted(list, i);
|
||||
}
|
||||
|
||||
private static <I extends Integer> void extracted(List<T> list, I i) {
|
||||
list.get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -492,6 +492,18 @@ class ExtractMethodAndDuplicatesInplaceTest: LightJavaCodeInsightTestCase() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testTypeParametersInNonStaticTarget(){
|
||||
JavaRefactoringSettings.getInstance().EXTRACT_STATIC_METHOD = true
|
||||
shouldSelectTargetClass("Inner in Test")
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testNonStaticExtractFromStaticInner(){
|
||||
shouldSelectTargetClass("Inner in Test")
|
||||
JavaRefactoringSettings.getInstance().EXTRACT_STATIC_METHOD = false
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testRefactoringListener(){
|
||||
templateTest {
|
||||
configureByFile("$BASE_PATH/${getTestName(false)}.java")
|
||||
|
||||
Reference in New Issue
Block a user