mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
introduce functional parameter: ignore parameters of containing method as they are available at call site
This commit is contained in:
+9
-2
@@ -661,7 +661,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase {
|
||||
|
||||
PsiExpression expression = factory
|
||||
.createExpressionFromText("new " + selectedType.getCanonicalText() + "() {" + methodText.get() + "}",
|
||||
methodToIntroduceParameter);
|
||||
elements[0]);
|
||||
expression = (PsiExpression)JavaCodeStyleManager.getInstance(project).shortenClassReferences(expression);
|
||||
|
||||
expression.putUserData(ElementToWorkOn.PARENT, commonParent);
|
||||
@@ -717,7 +717,14 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase {
|
||||
@Override
|
||||
public VariableData[] getChosenParameters() {
|
||||
final InputVariables inputVariables = getInputVariables();
|
||||
return inputVariables.getInputVariables().toArray(new VariableData[inputVariables.getInputVariables().size()]);
|
||||
List<VariableData> datas = new ArrayList<VariableData>();
|
||||
for (VariableData data : inputVariables.getInputVariables()) {
|
||||
if (data.variable instanceof PsiParameter) {
|
||||
continue;
|
||||
}
|
||||
datas.add(data);
|
||||
}
|
||||
return datas.toArray(new VariableData[datas.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-8
@@ -1,18 +1,16 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
void bar() {
|
||||
foo(1, new Consumer<Integer>() {
|
||||
public void accept(Integer i) {
|
||||
System.out.println(i);
|
||||
System.out.println(i);
|
||||
foo(new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(1);
|
||||
System.out.println(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void foo(int i, Consumer<Integer> anObject) {
|
||||
void foo(Runnable anObject) {
|
||||
|
||||
anObject.accept(i);
|
||||
anObject.run();
|
||||
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -1,19 +1,17 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
void bar() {
|
||||
foo(1, new Consumer<Integer>() {
|
||||
public void accept(Integer i) {
|
||||
System.out.println(i);
|
||||
System.out.println(i);
|
||||
foo(1, new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(1);
|
||||
System.out.println(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void foo(int i, Consumer<Integer> anObject) {
|
||||
void foo(int i, Runnable anObject) {
|
||||
if (i > 0) {
|
||||
|
||||
anObject.accept(i);
|
||||
anObject.run();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,12 +1,12 @@
|
||||
import java.util.function.Function;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
class Test {
|
||||
void bar() {
|
||||
foo(1, new Function<Integer,Boolean>() {
|
||||
public boolean apply(Integer i) {
|
||||
if (i > 0) {
|
||||
System.out.println(i);
|
||||
System.out.println(i);
|
||||
foo(new BooleanSupplier() {
|
||||
public boolean getAsBoolean() {
|
||||
if (1 > 0) {
|
||||
System.out.println(1);
|
||||
System.out.println(1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -14,9 +14,9 @@ class Test {
|
||||
});
|
||||
}
|
||||
|
||||
void foo(int i, Function<Integer, Boolean> anObject) {
|
||||
void foo(BooleanSupplier anObject) {
|
||||
|
||||
if (anObject.apply(i)) return;
|
||||
if (anObject.getAsBoolean()) return;
|
||||
|
||||
System.out.println("Hi");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user