mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
pull up: postpone type params replacement: substituted types can contain type params from base class with names that exist in current class (IDEA-87543)
This commit is contained in:
@@ -891,6 +891,7 @@ public class RefactoringUtil {
|
||||
final Iterable<PsiTypeParameter> parametersIterable,
|
||||
final PsiSubstitutor substitutor,
|
||||
final PsiElementFactory factory) {
|
||||
final Map<PsiElement, PsiElement> replacement = new LinkedHashMap<PsiElement, PsiElement>();
|
||||
for (PsiTypeParameter parameter : parametersIterable) {
|
||||
PsiType substitutedType = substitutor.substitute(parameter);
|
||||
if (substitutedType == null) {
|
||||
@@ -900,12 +901,17 @@ public class RefactoringUtil {
|
||||
final PsiElement element = reference.getElement();
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiTypeElement) {
|
||||
parent.replace(factory.createTypeElement(substitutedType));
|
||||
replacement.put(parent, factory.createTypeElement(substitutedType));
|
||||
} else if (element instanceof PsiJavaCodeReferenceElement && substitutedType instanceof PsiClassType) {
|
||||
element.replace(factory.createReferenceElementByType((PsiClassType)substitutedType));
|
||||
replacement.put(element, factory.createReferenceElementByType((PsiClassType)substitutedType));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PsiElement element : replacement.keySet()) {
|
||||
if (element.isValid()) {
|
||||
element.replace(replacement.get(element));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user