mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[java] JavaCodeStyleManagerImpl: use uniqName
GitOrigin-RevId: 2421439a99da70d887810de098a000fd71b65692
This commit is contained in:
committed by
intellij-monorepo-bot
parent
832b80f75b
commit
10310458ce
@@ -1107,14 +1107,8 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
|
||||
boolean allowShadowing,
|
||||
Predicate<? super PsiVariable> canBeReused) {
|
||||
PsiElement scope = PsiTreeUtil.getNonStrictParentOfType(place, PsiStatement.class, PsiCodeBlock.class, PsiMethod.class);
|
||||
for (int index = 0; ; index++) {
|
||||
String name = index > 0 ? baseName + index : baseName;
|
||||
if (hasConflictingVariable(place, name, allowShadowing) ||
|
||||
lookForward && hasConflictingVariableAfterwards(scope, name, canBeReused)) {
|
||||
continue;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
return NameUtilCore.uniqName(baseName, name -> hasConflictingVariable(place, name, allowShadowing) ||
|
||||
lookForward && hasConflictingVariableAfterwards(scope, name, canBeReused));
|
||||
}
|
||||
|
||||
private static boolean hasConflictingVariable(@Nullable PsiElement place, @NotNull String name, boolean allowShadowing) {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
class Test{
|
||||
int myP1;
|
||||
private final int myP11;
|
||||
private final int myP3;
|
||||
int myP2;
|
||||
|
||||
Test(int p1, int p2){
|
||||
myP11 = p1;
|
||||
myP3 = p1;
|
||||
myP2 = p2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
class Test{
|
||||
int myP1;
|
||||
int myP2;
|
||||
private int myP11;
|
||||
private int myP3;
|
||||
|
||||
void f(int p1, int p2){
|
||||
myP11 = p1;
|
||||
myP3 = p1;
|
||||
int myP2 = p1;
|
||||
p1 = 0;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ class Dependency2 {
|
||||
private static boolean intersect(@NotNull Set<String> ids1, @NotNull Set<String> ids2) {
|
||||
while (true) {
|
||||
if (ids1.size() > ids2.size()) {
|
||||
Set<String> ids11 = ids1;
|
||||
Set<String> ids3 = ids1;
|
||||
ids1 = ids2;
|
||||
ids2 = ids11;
|
||||
ids2 = ids3;
|
||||
continue;
|
||||
}
|
||||
for (String id : ids1) {
|
||||
|
||||
@@ -7,10 +7,10 @@ public class QualifiedNewTest {
|
||||
public class C2User {
|
||||
public void test() {
|
||||
C2 c2 = new C2();
|
||||
final C2 c21 = c2;
|
||||
final C2 c3 = c2;
|
||||
Object inner = new Object() {
|
||||
public void doStuff() {
|
||||
System.out.println(c21.a);
|
||||
System.out.println(c3.a);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class TestClass {
|
||||
public void test() {
|
||||
T2 t21 = 1 >;<T1 x="s1"><T2 t2= t21;
|
||||
T2 t3 = 1 >;<T1 x="s1"><T2 t2= t3;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user