mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
change class signature: process diamond (IDEA-125236)
This commit is contained in:
+7
@@ -96,6 +96,13 @@ public class ChangeClassSignatureProcessor extends BaseRefactoringProcessor {
|
||||
PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)reference.getElement();
|
||||
PsiElement parent = referenceElement.getParent();
|
||||
if (parent instanceof PsiTypeElement && parent.getParent() instanceof PsiInstanceOfExpression) continue;
|
||||
if (parent instanceof PsiNewExpression && PsiUtil.isLanguageLevel7OrHigher(parent)) {
|
||||
final PsiReferenceParameterList parameterList = referenceElement.getParameterList();
|
||||
if (parameterList != null) {
|
||||
final PsiTypeElement[] parameterElements = parameterList.getTypeParameterElements();
|
||||
if (parameterElements.length == 1 && parameterElements[0].getType() instanceof PsiDiamondType) continue;
|
||||
}
|
||||
}
|
||||
if (parent instanceof PsiTypeElement || parent instanceof PsiNewExpression || parent instanceof PsiAnonymousClass ||
|
||||
parent instanceof PsiReferenceList) {
|
||||
if (!hadTypeParameters || referenceElement.getTypeParameters().length > 0) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class <caret>QueryParameter<T> {}
|
||||
|
||||
class UUU {
|
||||
QueryParameter<String> q = new QueryParameter<>();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class QueryParameter<T, I> {}
|
||||
|
||||
class UUU {
|
||||
QueryParameter<String, Integer> q = new QueryParameter<>();
|
||||
}
|
||||
+12
@@ -85,6 +85,18 @@ public class ChangeClassSignatureTest extends LightRefactoringTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public void testAddParamDiamond() throws Exception {
|
||||
doTest(new GenParams() {
|
||||
@Override
|
||||
public TypeParameterInfo[] gen(PsiClass aClass) throws IncorrectOperationException {
|
||||
return new TypeParameterInfo[] {
|
||||
new TypeParameterInfo(0),
|
||||
new TypeParameterInfo(aClass, "I", "Integer")
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testAddOneFirst() throws Exception {
|
||||
doTest(new GenParams() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user