mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-refactoring] Inline delegating variable: an ability to keep the current variable name
Fixes IDEA-371649 Inline variable using the later name GitOrigin-RevId: a31d332762af3721245af31841562ff48a0cb3a9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
439a3ccff8
commit
1cadb8a667
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
package com.siyeh.igfixes.inline;
|
||||
|
||||
class ArrayInitializer {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
package com.siyeh.igfixes.inline;
|
||||
|
||||
class CastNeeded {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class Comment {
|
||||
|
||||
Object x(String s) {
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
@@ -5,7 +6,7 @@ public class Demo {
|
||||
public static void main(String[] args) {
|
||||
var y = switch (1) {
|
||||
case 1:
|
||||
yield <caret>3;
|
||||
<caret> yield 3;
|
||||
default:
|
||||
yield 4;
|
||||
};
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
// "Inline variable" "true-preview"
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
List<String> test(List<String> list) {
|
||||
return <caret>list.stream()
|
||||
<caret> return list.stream()
|
||||
.map(String::toUpperCase)
|
||||
.map(String::trim)
|
||||
.toList();
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r1 = null) {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r1 = null; AutoCloseable r3 = null) {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r1 = null) {
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Inline variable|->Keep the 'vExposure' variable" "true-preview"
|
||||
package com.example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
static class ExposureSpecification {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<ExposureSpecification> vExposures = new ArrayList<>();
|
||||
|
||||
for (ExposureSpecification vExposure : vExposures) {
|
||||
// ... lines of code using exp ...
|
||||
System.out.println(vExposure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Inline variable|->Inline and rename 'vExposure' to 'exp'" "true-preview"
|
||||
package com.example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
static class ExposureSpecification {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<ExposureSpecification> vExposures = new ArrayList<>();
|
||||
|
||||
for (ExposureSpecification exp : vExposures) {
|
||||
// ... lines of code using exp ...
|
||||
System.out.println(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Inline variable|->Inline and rename 'vExposure' to 'exp'" "true-preview"
|
||||
package com.example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
static class ExposureSpecification {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<ExposureSpecification> vExposures = new ArrayList<>();
|
||||
|
||||
for (ExposureSpecification exp : vExposures) {
|
||||
System.out.println(exp);
|
||||
// ... lines of code using exp ...
|
||||
System.out.println(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
package com.siyeh.igfixes.inline;
|
||||
|
||||
class ArrayInitializer {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "false"
|
||||
class Base {
|
||||
{
|
||||
Descendant descendant = new Descendant();
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
package com.siyeh.igfixes.inline;
|
||||
|
||||
class CastNeeded {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class Comment {
|
||||
|
||||
Object x(String s) {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r1 = null; AutoCloseable <caret>r2 = r1) {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r1 = null; AutoCloseable <caret>r2 = r1; AutoCloseable r3 = null) {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// "Inline variable" "true-preview"
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r1 = null) {
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Inline variable|->Keep the 'vExposure' variable" "true-preview"
|
||||
package com.example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
static class ExposureSpecification {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<ExposureSpecification> vExposures = new ArrayList<>();
|
||||
|
||||
for (ExposureSpecification vExposure : vExposures) {
|
||||
ExposureSpecification e<caret>xp = vExposure;
|
||||
// ... lines of code using exp ...
|
||||
System.out.println(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Inline variable|->Inline and rename 'vExposure' to 'exp'" "true-preview"
|
||||
package com.example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
static class ExposureSpecification {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<ExposureSpecification> vExposures = new ArrayList<>();
|
||||
|
||||
for (ExposureSpecification vExposure : vExposures) {
|
||||
ExposureSpecification e<caret>xp = vExposure;
|
||||
// ... lines of code using exp ...
|
||||
System.out.println(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// "Inline variable|->Inline and rename 'vExposure' to 'exp'" "true-preview"
|
||||
package com.example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Demo {
|
||||
static class ExposureSpecification {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<ExposureSpecification> vExposures = new ArrayList<>();
|
||||
|
||||
for (ExposureSpecification vExposure : vExposures) {
|
||||
System.out.println(vExposure);
|
||||
ExposureSpecification e<caret>xp = vExposure;
|
||||
// ... lines of code using exp ...
|
||||
System.out.println(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user