mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
create from usage: ensure that refs for methods/locals are not mixed (IDEA-195066)
This commit is contained in:
@@ -500,7 +500,8 @@ public class CreateFromUsageUtils {
|
||||
final List<PsiReferenceExpression> result = new ArrayList<>();
|
||||
JavaRecursiveElementWalkingVisitor visitor = new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression expr) {
|
||||
if (expression instanceof PsiReferenceExpression) {
|
||||
if (expression instanceof PsiReferenceExpression &&
|
||||
(expr.getParent() instanceof PsiMethodCallExpression == expression.getParent() instanceof PsiMethodCallExpression)) {
|
||||
if (Comparing.equal(expr.getReferenceName(), ((PsiReferenceExpression)expression).getReferenceName()) && !isValidReference(expr, false)) {
|
||||
result.add(expr);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Create local variable 'a'" "true"
|
||||
class C {
|
||||
C builder() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
String a;
|
||||
builder().a(a).intValue();
|
||||
}
|
||||
|
||||
Integer a(String s) {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Create local variable 'a'" "true"
|
||||
class C {
|
||||
C builder() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
builder().a(<caret>a).intValue();
|
||||
}
|
||||
|
||||
Integer a(String s) {}
|
||||
}
|
||||
Reference in New Issue
Block a user