本文整理汇总了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"));
}
}
}