mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
name suggestions: skip pluralization when component type is the same as original (IDEA-89143)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user