Search in sources :

Example 16 with TypeMigrationUsageInfo

use of com.intellij.refactoring.typeMigration.usageInfo.TypeMigrationUsageInfo in project intellij-community by JetBrains.

the class ClassTypeArgumentMigrationProcessor method migrateClassTypeParameter.

public void migrateClassTypeParameter(final PsiReferenceParameterList referenceParameterList, final PsiClassType migrationType) {
    final PsiClass psiClass = PsiTreeUtil.getParentOfType(referenceParameterList, PsiClass.class);
    LOG.assertTrue(psiClass != null);
    final PsiClass superClass = psiClass.getSuperClass();
    LOG.assertTrue(superClass != null);
    myLabeler.getTypeEvaluator().setType(new TypeMigrationUsageInfo(superClass), migrationType);
    final Map<PsiElement, Pair<PsiReference[], PsiType>> roots = new HashMap<>();
    markTypeParameterUsages(psiClass, migrationType, referenceParameterList, roots);
    final Set<PsiElement> processed = new HashSet<>();
    for (Map.Entry<PsiElement, Pair<PsiReference[], PsiType>> entry : roots.entrySet()) {
        final PsiElement member = entry.getKey();
        final PsiType type = entry.getValue().second;
        if (member instanceof PsiParameter && ((PsiParameter) member).getDeclarationScope() instanceof PsiMethod) {
            myLabeler.migrateMethodCallExpressions(type, (PsiParameter) member, psiClass);
        }
        final PsiReference[] references = entry.getValue().first;
        for (PsiReference usage : references) {
            myLabeler.migrateRootUsageExpression(usage, processed);
        }
    }
}
Also used : TypeMigrationUsageInfo(com.intellij.refactoring.typeMigration.usageInfo.TypeMigrationUsageInfo) Pair(com.intellij.openapi.util.Pair)

Example 17 with TypeMigrationUsageInfo

use of com.intellij.refactoring.typeMigration.usageInfo.TypeMigrationUsageInfo in project intellij-community by JetBrains.

the class TypeEvaluator method getMigratedDeclarations.

public LinkedList<Pair<TypeMigrationUsageInfo, PsiType>> getMigratedDeclarations() {
    final LinkedList<Pair<TypeMigrationUsageInfo, PsiType>> list = new LinkedList<>();
    for (final TypeMigrationUsageInfo usageInfo : myTypeMap.keySet()) {
        final LinkedList<PsiType> types = myTypeMap.get(usageInfo);
        final PsiElement element = usageInfo.getElement();
        if (element instanceof PsiVariable || element instanceof PsiMethod) {
            list.addLast(Pair.create(usageInfo, types.getFirst()));
        }
    }
    return list;
}
Also used : LinkedList(java.util.LinkedList) TypeMigrationUsageInfo(com.intellij.refactoring.typeMigration.usageInfo.TypeMigrationUsageInfo) Pair(com.intellij.openapi.util.Pair)

Aggregations

TypeMigrationUsageInfo (com.intellij.refactoring.typeMigration.usageInfo.TypeMigrationUsageInfo)17 Pair (com.intellij.openapi.util.Pair)7 NotNull (org.jetbrains.annotations.NotNull)5 UsageInfo (com.intellij.usageView.UsageInfo)4 Logger (com.intellij.openapi.diagnostic.Logger)3 Comparing (com.intellij.openapi.util.Comparing)3 StringUtil (com.intellij.openapi.util.text.StringUtil)3 com.intellij.psi (com.intellij.psi)3 PsiImmediateClassType (com.intellij.psi.impl.source.PsiImmediateClassType)3 PsiTreeUtil (com.intellij.psi.util.PsiTreeUtil)3 PsiUtil (com.intellij.psi.util.PsiUtil)3 TypeConversionUtil (com.intellij.psi.util.TypeConversionUtil)3 PsiExtendedTypeVisitor (com.intellij.refactoring.typeCook.deductive.PsiExtendedTypeVisitor)3 OverriddenUsageInfo (com.intellij.refactoring.typeMigration.usageInfo.OverriddenUsageInfo)3 OverriderUsageInfo (com.intellij.refactoring.typeMigration.usageInfo.OverriderUsageInfo)3 Nullable (org.jetbrains.annotations.Nullable)3 GenerateMembersUtil (com.intellij.codeInsight.generation.GenerateMembersUtil)2 GetterSetterPrototypeProvider (com.intellij.codeInsight.generation.GetterSetterPrototypeProvider)2 JavaLanguage (com.intellij.lang.java.JavaLanguage)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2