mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java introduce constant: allow to replace multiple occurrences for field-anchor without initializer (IDEA-250412)
fix regression introduced by enabling extract variable from field initializer GitOrigin-RevId: c6dd97ec10ecec32f48a337482afb6900464f668
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e429717fa2
commit
6cfefc432f
+1
-1
@@ -81,7 +81,7 @@ public abstract class BaseOccurrenceManager implements OccurrenceManager {
|
||||
@Override
|
||||
public PsiElement getAnchorStatementForAllInScope(PsiElement scope) {
|
||||
PsiElement anchor = RefactoringUtil.getAnchorElementForMultipleExpressions(myOccurrences, scope);
|
||||
return anchor instanceof PsiField && !(anchor instanceof PsiEnumConstant) ? ((PsiField)anchor).getInitializer() : anchor;
|
||||
return anchor instanceof PsiField && ((PsiField)anchor).hasInitializer() && !(anchor instanceof PsiEnumConstant) ? ((PsiField)anchor).getInitializer() : anchor;
|
||||
}
|
||||
|
||||
private static boolean needToDeclareFinal(PsiExpression[] occurrences) {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
@SuppressWarnings("unused")
|
||||
String myField;
|
||||
String myField1 = "unu<caret>sed";
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
public static final String xxx = "unused";
|
||||
@SuppressWarnings(xxx)
|
||||
String myField;
|
||||
String myField1 = xxx;
|
||||
}
|
||||
@@ -180,6 +180,10 @@ public class IntroduceConstantTest extends LightJavaCodeInsightTestCase {
|
||||
doTestExpr();
|
||||
}
|
||||
|
||||
public void testConstantFromAnnotationOnFieldWithoutInitializer() {
|
||||
doTestExpr();
|
||||
}
|
||||
|
||||
public void testEscalateVisibility() {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
final PsiClass[] classes = ((PsiJavaFile)getFile()).getClasses();
|
||||
|
||||
Reference in New Issue
Block a user