mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ignore type substitution on override (IDEABKL-6365)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user