Search in sources :

Example 1 with PsiMigration

use of com.intellij.psi.PsiMigration in project intellij-community by JetBrains.

the class MigrationProcessor method performRefactoring.

protected void performRefactoring(@NotNull UsageInfo[] usages) {
    final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
    LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
    myRefsToShorten = new ArrayList<>();
    try {
        boolean sameShortNames = false;
        for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
            MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
            String newName = entry.getNewName();
            PsiElement element = entry.getType() == MigrationMapEntry.PACKAGE ? MigrationUtil.findOrCreatePackage(myProject, psiMigration, newName) : MigrationUtil.findOrCreateClass(myProject, psiMigration, newName);
            MigrationUtil.doMigration(element, newName, usages, myRefsToShorten);
            if (!sameShortNames && Comparing.strEqual(StringUtil.getShortName(entry.getOldName()), StringUtil.getShortName(entry.getNewName()))) {
                sameShortNames = true;
            }
        }
        if (!sameShortNames) {
            myRefsToShorten.clear();
        }
    } finally {
        a.finish();
        psiMigration.finish();
    }
}
Also used : LocalHistoryAction(com.intellij.history.LocalHistoryAction) PsiElement(com.intellij.psi.PsiElement) PsiMigration(com.intellij.psi.PsiMigration)

Example 2 with PsiMigration

use of com.intellij.psi.PsiMigration in project intellij-community by JetBrains.

the class MigrationProcessor method startMigration.

private PsiMigration startMigration(Project project) {
    final PsiMigration migration = PsiMigrationManager.getInstance(project).startMigration();
    findOrCreateEntries(project, migration);
    return migration;
}
Also used : PsiMigration(com.intellij.psi.PsiMigration)

Aggregations

PsiMigration (com.intellij.psi.PsiMigration)2 LocalHistoryAction (com.intellij.history.LocalHistoryAction)1 PsiElement (com.intellij.psi.PsiElement)1