ignore type substitution on override (IDEABKL-6365)

This commit is contained in:
Anna Kozlova
2012-05-23 21:45:54 +04:00
parent 1afebf45d2
commit 26c733b37a
4 changed files with 35 additions and 9 deletions
@@ -270,16 +270,13 @@ public class GenerateMembersUtil {
final PsiType parameterType = parameter.getType();
PsiType substituted = substituteType(substitutor, parameterType);
@NonNls String paramName = parameter.getName();
final String[] baseSuggestions = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, parameterType).names;
boolean isBaseNameGenerated = false;
for (String s : baseSuggestions) {
if (s.equals(paramName)) {
isBaseNameGenerated = true;
break;
}
boolean isBaseNameGenerated = true;
final boolean isSubstituted = substituted.equals(parameterType);
if (!isSubstituted && isBaseNameGenerated(codeStyleManager, TypeConversionUtil.erasure(parameterType), paramName)) {
isBaseNameGenerated = false;
}
if (paramName == null || isBaseNameGenerated && !substituted.equals(parameterType)) {
if (paramName == null || isBaseNameGenerated && !isSubstituted && isBaseNameGenerated(codeStyleManager, parameterType, paramName)) {
Pair<String, Integer> pair = m.get(substituted);
if (pair != null) {
paramName = pair.first + pair.second;
@@ -339,6 +336,18 @@ public class GenerateMembersUtil {
}
}
private static boolean isBaseNameGenerated(JavaCodeStyleManager codeStyleManager, PsiType parameterType, String paramName) {
final String[] baseSuggestions = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, parameterType).names;
boolean isBaseNameGenerated = false;
for (String s : baseSuggestions) {
if (s.equals(paramName)) {
isBaseNameGenerated = true;
break;
}
}
return isBaseNameGenerated;
}
private static void processAnnotations(Project project, PsiModifierList modifierList, GlobalSearchScope moduleScope) {
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
final Set<String> toRemove = new HashSet<String>();
@@ -0,0 +1,9 @@
interface Function<S> {
void fun(Function<S> function);
}
class Bar extends Function<String>{
public void fun(Function<String> function) {
<selection>//To change body of implemented methods use File | Settings | File Templates.</selection>
}
}
@@ -0,0 +1,7 @@
interface Function<S> {
void fun(Function<S> function);
}
class Bar extends Function<String>{
<caret>
}
@@ -35,6 +35,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
public void testSubstitutionInTypeParametersList() throws Exception { doTest(false); }
public void testTestMissed() throws Exception { doTest(false); }
public void testWildcard() throws Exception { doTest(false); }
public void testTypeParam() throws Exception { doTest(false); }
public void testLongFinalParameterList() throws Exception {
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();