suggest names: fix testdata caused by name suggested by left side

This commit is contained in:
Anna Kozlova
2017-05-26 12:00:34 +03:00
parent db574f59cf
commit 88e00f2f68
11 changed files with 25 additions and 24 deletions
@@ -787,8 +787,8 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)expr.getParent();
if (expr == assignmentExpression.getRExpression()) {
final PsiExpression leftExpression = assignmentExpression.getLExpression();
if (leftExpression instanceof PsiReferenceExpression && ((PsiReferenceExpression) leftExpression).getQualifier() == null) {
String name = leftExpression.getText();
if (leftExpression instanceof PsiReferenceExpression) {
String name = ((PsiReferenceExpression)leftExpression).getReferenceName();
if (name != null) {
final PsiElement resolve = ((PsiReferenceExpression)leftExpression).resolve();
if (resolve instanceof PsiVariable) {
@@ -800,7 +800,8 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
}
}
}
else if (expr.getParent() instanceof PsiLocalVariable) {
//skip places where name for this local variable is calculated, otherwise grab the name
else if (expr.getParent() instanceof PsiLocalVariable && variableKind != VariableKind.LOCAL_VARIABLE) {
PsiVariable variable = (PsiVariable)expr.getParent();
String variableName = variable.getName();
if (variableName != null) {
@@ -6,7 +6,7 @@ class Test {
newMethod(doubles[0] / i);
}
private void newMethod(double v) {
double progressResult = v;
private void newMethod(double progressResult1) {
double progressResult = progressResult1;
}
}
@@ -9,8 +9,8 @@ class Test {
newMethod(array[i], array2, i);
}
private void newMethod(int i, int[] array2, int i2) {
int sum = i2;
sum += array2[i2];
private void newMethod(int sum1, int[] array2, int i) {
int sum = sum1;
sum += array2[i];
}
}
@@ -4,8 +4,8 @@ class Test {
System.out.println(s1);
}
private String newMethod(String s, String s2) {
System.out.println(s2);
return s2;
private String newMethod(String s, String s11) {
System.out.println(s11);
return s11;
}
}
@@ -1,8 +1,8 @@
class InStaticInitializer {
public static final String s = "Hello World";
public static final String hello_world = "Hello World";
static {
System.out.println(s);
System.out.println(hello_world);
}
//Field must be placed before initializer or illegal forward reference will happen
}
@@ -1,12 +1,12 @@
class TestRefactoring {
public final Integer integer;
public final Integer toField;
public TestRefactoring() {
integer = new Integer("0");
toField = new Integer("0");
Runnable r = new Runnable() {
@Override
public void run() {
System.out.println(integer);
System.out.println(toField);
}
};
}
@@ -1,7 +1,7 @@
public class FieldTest {
public final int integer;
public final int ii;
void foo() {
integer = new Integer(0);
ii = new Integer(0);
}
}
@@ -1,6 +1,6 @@
class Test {
@Deprecated
public final String string = "";
public final String fo = "";
void foo() {
}
@@ -1,8 +1,8 @@
import java.util.*;
class Foo {
public final ArrayList<String> strings = new ArrayList<>();
public final ArrayList<String> l = new ArrayList<>();
{
List<String> l = strings;
List<String> l = this.l;
}
}
@@ -1,9 +1,9 @@
public class A {
private static final class Inner {
public final String string;
public final String str;
public Inner(Integer param) {
string = param.toString();
str = param.toString();
}
}
}
@@ -518,7 +518,7 @@ class Foo {
void "test vertical arrows in non-focused lookup"() {
String toType = "ArrayIndexOutOfBoundsException ind"
testArrows toType, LookupImpl.FocusDegree.UNFOCUSED, 0, 1
testArrows toType, LookupImpl.FocusDegree.UNFOCUSED, 0, 2
UISettings.instance.cycleScrolling = false
try {