create method from usage: guess return types by context of the same method calls (IDEA-199042)

This commit is contained in:
Anna.Kozlova
2018-09-19 13:27:43 +02:00
parent 39bc5a4966
commit 5cec08212e
3 changed files with 26 additions and 1 deletions

View File

@@ -517,8 +517,9 @@ public class CreateFromUsageUtils {
@Override public void visitMethodCallExpression(PsiMethodCallExpression expr) {
if (expression instanceof PsiMethodCallExpression) {
PsiMethod resolveMethod = ((PsiMethodCallExpression)expression).resolveMethod();
PsiReferenceExpression methodExpression = expr.getMethodExpression();
if (Comparing.equal(methodExpression.getReferenceName(), ((PsiMethodCallExpression) expression).getMethodExpression().getReferenceName())) {
if (Comparing.equal(methodExpression.getReferenceName(), ((PsiMethodCallExpression) expression).getMethodExpression().getReferenceName()) && methodExpression.resolve() == resolveMethod) {
result.add(expr.getMethodExpression());
}
}

View File

@@ -0,0 +1,14 @@
// "Create method 'test'" "true"
public class Test {
public Test(Impl impl) {
impl.test(test());
}
private String test() {
return null;
}
}
class Impl {
void test(String s) {}
}

View File

@@ -0,0 +1,10 @@
// "Create method 'test'" "true"
public class Test {
public Test(Impl impl) {
impl.test(te<caret>st());
}
}
class Impl {
void test(String s) {}
}