mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[command-completion] IDEA-375693 Command completion. Java. Impossible to rename parameters
- simplify conditions - more tests GitOrigin-RevId: 7d9e80bfd3567e8181c445b0ca6256f6fc5c82d2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7561b57236
commit
14789d0e75
+1
-2
@@ -27,8 +27,7 @@ class JavaRenameActionCommandProvider: AbstractRenameActionCommandProvider() {
|
||||
//<..> place to call 'rename'
|
||||
val method = element.parentOfType<PsiMethod>()
|
||||
if (method != null &&
|
||||
(method.identifyingElement?.textRange?.startOffset ?: Int.MAX_VALUE) < currentOffset &&
|
||||
((!method.parameterList.textRange.contains(currentOffset) && (method.body?.lBrace?.textRange?.startOffset ?: 0) >= currentOffset) ||
|
||||
(method.identifyingElement?.textRange?.endOffset == currentOffset ||
|
||||
method.parameterList.textRange.endOffset == currentOffset ||
|
||||
method.body?.rBrace?.textRange?.endOffset == currentOffset)) return method.identifyingElement?.textRange?.endOffset
|
||||
|
||||
|
||||
+27
-2
@@ -443,7 +443,11 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
}
|
||||
}""".trimIndent())
|
||||
val elements = myFixture.completeBasic()
|
||||
assertTrue(elements.any { element -> element.lookupString.contains("Rename", ignoreCase = true) })
|
||||
val lookupElement = elements
|
||||
.firstOrNull { element -> element.lookupString.contains("rename", ignoreCase = true) }
|
||||
?.`as`(CommandCompletionLookupElement::class.java)
|
||||
assertNotNull(lookupElement)
|
||||
assertEquals(TextRange(19, 22), (lookupElement as CommandCompletionLookupElement).highlighting?.range)
|
||||
}
|
||||
|
||||
fun testRenameMethod2() {
|
||||
@@ -456,7 +460,28 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
}.<caret>
|
||||
}""".trimIndent())
|
||||
val elements = myFixture.completeBasic()
|
||||
assertTrue(elements.any { element -> element.lookupString.contains("Rename", ignoreCase = true) })
|
||||
val lookupElement = elements
|
||||
.firstOrNull { element -> element.lookupString.contains("rename", ignoreCase = true) }
|
||||
?.`as`(CommandCompletionLookupElement::class.java)
|
||||
assertNotNull(lookupElement)
|
||||
assertEquals(TextRange(19, 22), (lookupElement as CommandCompletionLookupElement).highlighting?.range)
|
||||
}
|
||||
|
||||
fun testRenameMethod3() {
|
||||
Registry.get("ide.completion.command.force.enabled").setValue(true, getTestRootDisposable())
|
||||
myFixture.configureByText(JavaFileType.INSTANCE, """
|
||||
class A {
|
||||
void foo.<caret>() {
|
||||
String y = "1";
|
||||
System.out.println(y);
|
||||
}
|
||||
}""".trimIndent())
|
||||
val elements = myFixture.completeBasic()
|
||||
val lookupElement = elements
|
||||
.firstOrNull { element -> element.lookupString.contains("rename", ignoreCase = true) }
|
||||
?.`as`(CommandCompletionLookupElement::class.java)
|
||||
assertNotNull(lookupElement)
|
||||
assertEquals(TextRange(19, 22), (lookupElement as CommandCompletionLookupElement).highlighting?.range)
|
||||
}
|
||||
|
||||
fun testParameterRename() {
|
||||
|
||||
Reference in New Issue
Block a user