mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
override: fix param names in javadoc (IDEA-114557)
This commit is contained in:
@@ -26,6 +26,8 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.*;
|
||||
@@ -261,12 +263,12 @@ public class GenerateMembersUtil {
|
||||
|
||||
try {
|
||||
final PsiMethod resultMethod = createMethod(factory, sourceMethod, target);
|
||||
copyDocComment(sourceMethod, resultMethod, factory);
|
||||
copyModifiers(sourceMethod.getModifierList(), resultMethod.getModifierList());
|
||||
final PsiSubstitutor collisionResolvedSubstitutor =
|
||||
substituteTypeParameters(factory, target, sourceMethod.getTypeParameterList(), resultMethod.getTypeParameterList(), substitutor, sourceMethod);
|
||||
substituteReturnType(PsiManager.getInstance(project), resultMethod, sourceMethod.getReturnType(), collisionResolvedSubstitutor);
|
||||
substituteParameters(factory, codeStyleManager, sourceMethod.getParameterList(), resultMethod.getParameterList(), collisionResolvedSubstitutor, target);
|
||||
copyDocComment(sourceMethod, resultMethod, factory);
|
||||
final List<PsiClassType> thrownTypes = ExceptionUtil.collectSubstituted(collisionResolvedSubstitutor, sourceMethod.getThrowsList().getReferencedTypes());
|
||||
if (target instanceof PsiClass) {
|
||||
final PsiClass[] supers = ((PsiClass)target).getSupers();
|
||||
@@ -435,6 +437,18 @@ public class GenerateMembersUtil {
|
||||
target.addAfter(factory.createDocCommentFromText(docComment.getText()), null);
|
||||
}
|
||||
}
|
||||
final PsiParameter[] sourceParameters = source.getParameterList().getParameters();
|
||||
final PsiParameterList targetParameterList = target.getParameterList();
|
||||
RefactoringUtil.fixJavadocsForParams(target, new HashSet<PsiParameter>(Arrays.asList(targetParameterList.getParameters())), new Condition<Pair<PsiParameter, String>>() {
|
||||
@Override
|
||||
public boolean value(Pair<PsiParameter, String> pair) {
|
||||
final int parameterIndex = targetParameterList.getParameterIndex(pair.first);
|
||||
if (parameterIndex >= 0 && parameterIndex < sourceParameters.length) {
|
||||
return Comparing.strEqual(pair.second, sourceParameters[parameterIndex].getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.*;
|
||||
abstract class IX<T> {
|
||||
/**
|
||||
* @param t the param
|
||||
*/
|
||||
abstract void foo(T t){}
|
||||
}
|
||||
|
||||
class XXC extends IX<List<String>> {
|
||||
/**
|
||||
* @param strings the param
|
||||
*/
|
||||
@Override
|
||||
void foo(List<String> strings) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.util.*;
|
||||
abstract class IX<T> {
|
||||
/**
|
||||
* @param t the param
|
||||
*/
|
||||
abstract void foo(T t){}
|
||||
}
|
||||
|
||||
class XXC extends IX<List<String>> {
|
||||
<caret>
|
||||
}
|
||||
@@ -51,6 +51,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
|
||||
|
||||
public void testSimple() { doTest(true); }
|
||||
public void testAnnotation() { doTest(true); }
|
||||
public void testJavadocForChangedParamName() { doTest(true); }
|
||||
public void testIncomplete() { doTest(false); }
|
||||
public void testSubstitutionInTypeParametersList() { doTest(false); }
|
||||
public void testTestMissed() { doTest(false); }
|
||||
|
||||
Reference in New Issue
Block a user