mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
resolve conflicting names when rename to 'ignored' (IDEA-184092)
This commit is contained in:
+2
-1
@@ -16,10 +16,11 @@
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RenameToIgnoredFix extends RenameElementFix {
|
||||
public RenameToIgnoredFix(@NotNull PsiNamedElement element) {
|
||||
super(element, "ignored");
|
||||
super(element, JavaCodeStyleManager.getInstance(element.getProject()).suggestUniqueVariableName("ignored", element, true));
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class Test23 {
|
||||
void m() throws Exception {
|
||||
try (FooContext fo<caret>o = new FooContext()) {
|
||||
try (BarContext ignored = new BarContext()) {
|
||||
fooBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fooBar() {
|
||||
|
||||
}
|
||||
|
||||
private class FooContext implements AutoCloseable {
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class BarContext implements AutoCloseable{
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class Test23 {
|
||||
void m() throws Exception {
|
||||
try (FooContext ig<caret>nored1 = new FooContext()) {
|
||||
try (BarContext ignored = new BarContext()) {
|
||||
fooBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fooBar() {
|
||||
|
||||
}
|
||||
|
||||
private class FooContext implements AutoCloseable {
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class BarContext implements AutoCloseable{
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -16,7 +16,9 @@
|
||||
package com.intellij.java.codeInsight.daemon;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiField;
|
||||
@@ -55,7 +57,15 @@ public class LightUnusedHighlightingFixtureTest extends LightCodeInsightFixtureT
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
|
||||
public void testConflictingIgnoreParameters() {
|
||||
String testFileName = getTestName(false);
|
||||
myFixture.configureByFile(testFileName + ".java");
|
||||
IntentionAction action = myFixture.getAvailableIntention(
|
||||
CodeInsightBundle.message("rename.named.element.text", "foo", "ignored1"));
|
||||
assertNotNull(action);
|
||||
myFixture.launchAction(action);
|
||||
myFixture.checkResultByFile(testFileName + "_after.java", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
|
||||
Reference in New Issue
Block a user