Java: create dependent constant from usage in interface correctly (IDEA-337008)

GitOrigin-RevId: 3afbc697d94e692278ea74fe73fa3bc8982e50af
This commit is contained in:
Bas Leijdekkers
2023-11-06 11:17:04 +00:00
committed by intellij-monorepo-bot
parent 5fb47bfc3e
commit 38649ac539
4 changed files with 14 additions and 12 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.lang.java.actions
import com.intellij.codeInsight.CodeInsightUtil.positionCursor
@@ -50,14 +50,8 @@ internal class JavaFieldRenderer(
private val modifiersToRender: Collection<JvmModifier>
get() {
return if (constantField) {
if (targetClass.isInterface) {
// interface fields are public static final implicitly, so modifiers don't have to be rendered
request.modifiers - constantModifiers - visibilityModifiers
}
else {
// render static final explicitly
request.modifiers + constantModifiers
}
// render static final explicitly
request.modifiers + constantModifiers
}
else {
// render as is
@@ -0,0 +1,5 @@
// "Create constant field 'SOME_REGEXP'" "true-preview"
interface IntroduceConstant {
String SOME_REGEXP = ;
String SOME_PATTERN = SOME_REGEXP;
}
@@ -0,0 +1,4 @@
// "Create constant field 'SOME_REGEXP'" "true-preview"
interface IntroduceConstant {
String SOME_PATTERN = SOME_RE<caret>GEXP;
}
@@ -64,9 +64,8 @@ public class CreateFieldFromUsageTest extends LightQuickFixTestCase {
doSingleTest();
}
public void testDependantConstant() {
doSingleTest();
}
public void testDependantConstant() { doSingleTest(); }
public void testDependantConstant2() { doSingleTest(); }
public void testArrayBraces() {
doSingleTest();