check for method type params inclusive (IDEA-56192)

This commit is contained in:
unknown
2010-07-01 13:37:08 +04:00
committed by unknown
parent f25abb008c
commit d63f1f294e
4 changed files with 18 additions and 2 deletions
@@ -1214,7 +1214,7 @@ public class RefactoringUtil {
final PsiElement resolved = reference.resolve();
if (resolved instanceof PsiTypeParameter) {
final PsiTypeParameter typeParameter = (PsiTypeParameter)resolved;
if (PsiTreeUtil.isAncestor(typeParameter.getOwner(), element, true)) {
if (PsiTreeUtil.isAncestor(typeParameter.getOwner(), element, false)) {
used.add(typeParameter);
}
}
@@ -1226,7 +1226,7 @@ public class RefactoringUtil {
super.visitExpression(expression);
final PsiType type = expression.getType();
final PsiClass resolved = PsiUtil.resolveClassInType(type);
if (resolved instanceof PsiTypeParameter && PsiTreeUtil.isAncestor(((PsiTypeParameter)resolved).getOwner(), element, true)){
if (resolved instanceof PsiTypeParameter && PsiTreeUtil.isAncestor(((PsiTypeParameter)resolved).getOwner(), element, false)){
used.add((PsiTypeParameter)resolved);
}
}
@@ -0,0 +1,5 @@
class C {
private static <T> List<T> getTopLevelItems() {
return null;
}
}
@@ -0,0 +1,5 @@
class C {
private <T> List<T> ge<caret>tTopLevelItems() {
return null;
}
}
@@ -164,6 +164,12 @@ public class MakeMethodStaticTest extends LightCodeInsightTestCase {
checkResultByFile("/refactoring/makeMethodStatic/after22.java");
}
public void testPreserveTypeParams() throws Exception {
configureByFile("/refactoring/makeMethodStatic/beforePreserveTypeParams.java");
performWithFields();
checkResultByFile("/refactoring/makeMethodStatic/afterPreserveTypeParams.java");
}
private void perform(boolean addClassParameter) {
PsiElement element = TargetElementUtilBase.findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
assertTrue(element instanceof PsiMethod);