name suggestions: skip pluralization when component type is the same as original (IDEA-89143)

This commit is contained in:
anna
2012-07-31 16:51:28 +02:00
parent 1b5df35a54
commit ecb0f64aa1
4 changed files with 39 additions and 1 deletions
@@ -0,0 +1,9 @@
abstract class Path implements Iterable<Path>{}
class Paths {
public static Path get(String s) {return null;}
}
class Usage {
public static void main(String[] args) {
Path path = Paths.get("");
}
}
@@ -0,0 +1,9 @@
abstract class Path implements Iterable<Path>{}
class Paths {
public static Path get(String s) {return null;}
}
class Usage {
public static void main(String[] args) {
<selection>Paths.get("")</selection>
}
}
@@ -282,6 +282,26 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("collection", true, true, true, "java.util.List<? extends java.util.Collection<?>>"));
}
public void testNameSuggestion() throws Exception {
final String expectedTypeName = "Path";
doTest(new MockIntroduceVariableHandler("path", true, false, false, expectedTypeName) {
@Override
public IntroduceVariableSettings getSettings(Project project, Editor editor,
PsiExpression expr, PsiExpression[] occurrences,
TypeSelectorManagerImpl typeSelectorManager,
boolean declareFinalIfAll,
boolean anyAssignmentLHS,
InputValidator validator,
PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
final PsiType type = typeSelectorManager.getDefaultType();
Assert.assertTrue(type.getPresentableText(), type.getPresentableText().equals(expectedTypeName));
Assert.assertEquals("path", IntroduceVariableBase.getSuggestedName(type, expr).names[0]);
return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS,
validator, anchor, replaceChoice);
}
});
}
public void testSiblingInnerClassType() throws Exception {
doTest(new MockIntroduceVariableHandler("vari", true, false, false, "A.B") {
@Override