当前位置: 首页>>代码示例>>Java>>正文


Java RefactoringListenerManagerImpl类代码示例

本文整理汇总了Java中com.intellij.refactoring.listeners.impl.RefactoringListenerManagerImpl的典型用法代码示例。如果您正苦于以下问题:Java RefactoringListenerManagerImpl类的具体用法?Java RefactoringListenerManagerImpl怎么用?Java RefactoringListenerManagerImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RefactoringListenerManagerImpl类属于com.intellij.refactoring.listeners.impl包,在下文中一共展示了RefactoringListenerManagerImpl类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRefactoring

import com.intellij.refactoring.listeners.impl.RefactoringListenerManagerImpl; //导入依赖的package包/类
private void doRefactoring(@NotNull Collection<UsageInfo> usageInfoSet) {
 for (Iterator<UsageInfo> iterator = usageInfoSet.iterator(); iterator.hasNext();) {
    UsageInfo usageInfo = iterator.next();
    final PsiElement element = usageInfo.getElement();
    if (element == null || !isToBeChanged(usageInfo)) {
      iterator.remove();
    }
  }

  LocalHistoryAction action = LocalHistory.getInstance().startAction(getCommandName());

  final UsageInfo[] writableUsageInfos = usageInfoSet.toArray(new UsageInfo[usageInfoSet.size()]);
  try {
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    RefactoringListenerManagerImpl listenerManager = (RefactoringListenerManagerImpl)RefactoringListenerManager.getInstance(myProject);
    myTransaction = listenerManager.startTransaction();
    final Map<RefactoringHelper, Object> preparedData = new HashMap<RefactoringHelper, Object>();
    final Runnable prepareHelpersRunnable = new Runnable() {
      @Override
      public void run() {
        for (RefactoringHelper helper : Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
          preparedData.put(helper, helper.prepareOperation(writableUsageInfos));
        }
      }
    };

    ProgressManager.getInstance().runProcessWithProgressSynchronously(prepareHelpersRunnable, "Prepare ...", false, myProject);

    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        performRefactoring(writableUsageInfos);
      }
    });

    for(Map.Entry<RefactoringHelper, Object> e: preparedData.entrySet()) {
      //noinspection unchecked
      e.getKey().performOperation(myProject, e.getValue());
    }
    myTransaction.commit();
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        performPsiSpoilingRefactoring();
      }
    });
  }
  finally {
    action.finish();
  }

  int count = writableUsageInfos.length;
  if (count > 0) {
    StatusBarUtil.setStatusBarInfo(myProject, RefactoringBundle.message("statusBar.refactoring.result", count));
  }
  else {
    if (!isPreviewUsages(writableUsageInfos)) {
      StatusBarUtil.setStatusBarInfo(myProject, RefactoringBundle.message("statusBar.noUsages"));
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:62,代码来源:BaseRefactoringProcessor.java


注:本文中的com.intellij.refactoring.listeners.impl.RefactoringListenerManagerImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。