Java 类com.intellij.psi.PsiMigration 实例源码

项目:intellij-ce-playground    文件:MigrationProcessor.java   
protected void performRefactoring(@NotNull UsageInfo[] usages) {
  final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());

  try {
    for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
      MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
      if (entry.getType() == MigrationMapEntry.PACKAGE) {
        MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
      if (entry.getType() == MigrationMapEntry.CLASS) {
        MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
    }

    for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
      Object preparedData = helper.prepareOperation(usages);
      //noinspection unchecked
      helper.performOperation(myProject, preparedData);
    }
  }
  finally {
    a.finish();
    psiMigration.finish();
  }
}
项目:tools-idea    文件:MigrationProcessor.java   
protected void performRefactoring(UsageInfo[] usages) {
  final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());

  try {
    for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
      MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
      if (entry.getType() == MigrationMapEntry.PACKAGE) {
        MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
      if (entry.getType() == MigrationMapEntry.CLASS) {
        MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
    }

    for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
      Object preparedData = helper.prepareOperation(usages);
      //noinspection unchecked
      helper.performOperation(myProject, preparedData);
    }
  }
  finally {
    a.finish();
    psiMigration.finish();
  }
}
项目:intellij-ce-playground    文件:PsiMigrationManager.java   
/**
 * Initiates a migrate refactoring. The refactoring is finished when
 * {@link com.intellij.psi.PsiMigration#finish()} is called.
 *
 * @return the migrate operation object.
 */
@NotNull
public PsiMigration startMigration() {
  LOG.assertTrue(myCurrentMigration == null);
  myCurrentMigration = new PsiMigrationImpl(this, JavaPsiFacade.getInstance(myProject),
                                            (PsiManagerImpl)PsiManager.getInstance(myProject));
  return myCurrentMigration;
}
项目:intellij-ce-playground    文件:MigrationProcessor.java   
private void findOrCreateEntries(Project project, final PsiMigration migration) {
  for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
    MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
    if (entry.getType() == MigrationMapEntry.PACKAGE) {
      MigrationUtil.findOrCreatePackage(project, migration, entry.getOldName());
    }
    else {
      MigrationUtil.findOrCreateClass(project, migration, entry.getOldName());
    }
  }
}
项目:tools-idea    文件:PsiMigrationManager.java   
/**
 * Initiates a migrate refactoring. The refactoring is finished when
 * {@link com.intellij.psi.PsiMigration#finish()} is called.
 *
 * @return the migrate operation object.
 */
@NotNull
public PsiMigration startMigration() {
  LOG.assertTrue(myCurrentMigration == null);
  myCurrentMigration = new PsiMigrationImpl(this, JavaPsiFacade.getInstance(myProject),
                                            (PsiManagerImpl)PsiManager.getInstance(myProject));
  return myCurrentMigration;
}
项目:tools-idea    文件:MigrationProcessor.java   
private void findOrCreateEntries(Project project, final PsiMigration migration) {
  for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
    MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
    if (entry.getType() == MigrationMapEntry.PACKAGE) {
      MigrationUtil.findOrCreatePackage(project, migration, entry.getOldName());
    }
    else {
      MigrationUtil.findOrCreateClass(project, migration, entry.getOldName());
    }
  }
}
项目:consulo-java    文件:PsiMigrationManager.java   
/**
 * Initiates a migrate refactoring. The refactoring is finished when
 * {@link com.intellij.psi.PsiMigration#finish()} is called.
 *
 * @return the migrate operation object.
 */
@NotNull
public PsiMigration startMigration() {
  LOG.assertTrue(myCurrentMigration == null);
  myCurrentMigration = new PsiMigrationImpl(this, JavaPsiFacade.getInstance(myProject),
                                            (PsiManagerImpl)PsiManager.getInstance(myProject));
  return myCurrentMigration;
}
项目:consulo-java    文件:MigrationProcessor.java   
private void findOrCreateEntries(Project project, final PsiMigration migration)
{
    for(int i = 0; i < myMigrationMap.getEntryCount(); i++)
    {
        MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
        if(entry.getType() == MigrationMapEntry.PACKAGE)
        {
            MigrationUtil.findOrCreatePackage(project, migration, entry.getOldName());
        }
        else
        {
            MigrationUtil.findOrCreateClass(project, migration, entry.getOldName());
        }
    }
}
项目:consulo-java    文件:MigrationProcessor.java   
@Override
protected void performRefactoring(@NotNull UsageInfo[] usages)
{
    finishFindMigration();
    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();
    }
}
项目:consulo-java    文件:MigrationUtil.java   
static PsiPackage findOrCreatePackage(Project project, final PsiMigration migration, final String qName)
{
    PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(qName);
    if(aPackage != null)
    {
        return aPackage;
    }
    else
    {
        return WriteAction.compute(() -> migration.createPackage(qName));
    }
}
项目:consulo-java    文件:MigrationUtil.java   
static PsiClass findOrCreateClass(Project project, final PsiMigration migration, final String qName)
{
    PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(qName, GlobalSearchScope.allScope(project));
    if(aClass == null)
    {
        aClass = WriteAction.compute(() -> migration.createClass(qName));
    }
    return aClass;
}
项目:intellij-ce-playground    文件:MigrationProcessor.java   
private PsiMigration startMigration(Project project) {
  final PsiMigration migration = PsiMigrationManager.getInstance(project).startMigration();
  findOrCreateEntries(project, migration);
  return migration;
}
项目:tools-idea    文件:MigrationProcessor.java   
private PsiMigration startMigration(Project project) {
  final PsiMigration migration = PsiMigrationManager.getInstance(project).startMigration();
  findOrCreateEntries(project, migration);
  return migration;
}
项目:consulo-java    文件:MigrationProcessor.java   
private PsiMigration startMigration(Project project)
{
    final PsiMigration migration = PsiMigrationManager.getInstance(project).startMigration();
    findOrCreateEntries(project, migration);
    return migration;
}
项目:consulo-java    文件:MigrationUtil.java   
public static UsageInfo[] findPackageUsages(Project project, PsiMigration migration, String qName, SearchScope searchScope)
{
    PsiPackage aPackage = findOrCreatePackage(project, migration, qName);

    return findRefs(aPackage, searchScope);
}
项目:consulo-java    文件:MigrationUtil.java   
public static UsageInfo[] findClassUsages(Project project, PsiMigration migration, String qName, SearchScope searchScope)
{
    PsiClass aClass = findOrCreateClass(project, migration, qName);

    return findRefs(aClass, searchScope);
}