本文整理汇总了Java中com.intellij.refactoring.ui.ConflictsDialog.showAndGet方法的典型用法代码示例。如果您正苦于以下问题:Java ConflictsDialog.showAndGet方法的具体用法?Java ConflictsDialog.showAndGet怎么用?Java ConflictsDialog.showAndGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.refactoring.ui.ConflictsDialog
的用法示例。
在下文中一共展示了ConflictsDialog.showAndGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doOKAction
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected void doOKAction() {
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
if (myCreateInnerClassRb.isSelected()) {
final PsiClass innerClass = myTargetClass.findInnerClassByName(myInnerClassName.getText(), false);
if (innerClass != null) {
conflicts.putValue(innerClass, "Inner class " + myInnerClassName.getText() + " already defined in class " + myTargetClass.getName());
}
}
if (conflicts.size() > 0) {
final ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts()) close(CANCEL_EXIT_CODE);
return;
}
}
final JCheckBox makeVarargsCb = myCreateInnerClassRb.isSelected() ? myCbMakeVarargs : myCbMakeVarargsAnonymous;
if (makeVarargsCb != null && makeVarargsCb.isSelected()) {
final VariableData data = myInputVariables[myInputVariables.length - 1];
if (data.type instanceof PsiArrayType) {
data.type = new PsiEllipsisType(((PsiArrayType)data.type).getComponentType());
}
}
super.doOKAction();
}
示例2: preprocessUsages
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected final boolean preprocessUsages(@NotNull final Ref<UsageInfo[]> refUsages) {
UsageInfo[] usagesIn = refUsages.get();
if (myPrepareSuccessfulSwingThreadCallback != null) {
MultiMap<PsiElement, String> conflicts = getConflictDescriptions(usagesIn);
if (conflicts.size() > 0) {
ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, refUsages.get());
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
if(!mySettings.isChangeSignature()) {
refUsages.set(filterInternalUsages(usagesIn));
}
}
final Set<UsageInfo> toMakeStatic = new LinkedHashSet<UsageInfo>();
refUsages.set(filterOverriding(usagesIn, toMakeStatic));
if (!findAdditionalMembers(toMakeStatic)) return false;
prepareSuccessful();
return true;
}
示例3: showConflicts
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected boolean showConflicts(@NotNull MultiMap<PsiElement, String> conflicts, @Nullable final UsageInfo[] usages) {
if (!conflicts.isEmpty() && ApplicationManager.getApplication().isUnitTestMode()) {
if (!ConflictsInTestsException.isTestIgnore()) throw new ConflictsInTestsException(conflicts.values());
return true;
}
if (myPrepareSuccessfulSwingThreadCallback != null && !conflicts.isEmpty()) {
final String refactoringId = getRefactoringId();
if (refactoringId != null) {
RefactoringEventData conflictUsages = new RefactoringEventData();
conflictUsages.putUserData(RefactoringEventData.CONFLICTS_KEY, conflicts.values());
myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
.conflictsDetected(refactoringId, conflictUsages);
}
final ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, usages);
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
prepareSuccessful();
return true;
}
示例4: showConflicts
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected boolean showConflicts(@Nonnull MultiMap<PsiElement, String> conflicts, @Nullable final UsageInfo[] usages) {
if (!conflicts.isEmpty() && ApplicationManager.getApplication().isUnitTestMode()) {
if (!ConflictsInTestsException.isTestIgnore()) throw new ConflictsInTestsException(conflicts.values());
return true;
}
if (myPrepareSuccessfulSwingThreadCallback != null && !conflicts.isEmpty()) {
final String refactoringId = getRefactoringId();
if (refactoringId != null) {
RefactoringEventData conflictUsages = new RefactoringEventData();
conflictUsages.putUserData(RefactoringEventData.CONFLICTS_KEY, conflicts.values());
myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
.conflictsDetected(refactoringId, conflictUsages);
}
final ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, usages);
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
prepareSuccessful();
return true;
}
示例5: preprocessUsages
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
for (ChangeSignatureUsageProcessor processor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) {
if (!processor.setupDefaultValues(myChangeInfo, refUsages, myProject)) return false;
}
MultiMap<PsiElement, String> conflictDescriptions = new MultiMap<PsiElement, String>();
for (ChangeSignatureUsageProcessor usageProcessor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) {
final MultiMap<PsiElement, String> conflicts = usageProcessor.findConflicts(myChangeInfo, refUsages);
for (PsiElement key : conflicts.keySet()) {
Collection<String> collection = conflictDescriptions.get(key);
if (collection.size() == 0) collection = new HashSet<String>();
collection.addAll(conflicts.get(key));
conflictDescriptions.put(key, collection);
}
}
final UsageInfo[] usagesIn = refUsages.get();
RenameUtil.addConflictDescriptions(usagesIn, conflictDescriptions);
Set<UsageInfo> usagesSet = new HashSet<UsageInfo>(Arrays.asList(usagesIn));
RenameUtil.removeConflictUsages(usagesSet);
if (!conflictDescriptions.isEmpty()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new ConflictsInTestsException(conflictDescriptions.values());
}
if (myPrepareSuccessfulSwingThreadCallback != null) {
ConflictsDialog dialog = prepareConflictsDialog(conflictDescriptions, usagesIn);
if (!dialog.showAndGet()) {
if (dialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
}
if (myChangeInfo.isReturnTypeChanged()) {
askToRemoveCovariantOverriders(usagesSet);
}
refUsages.set(usagesSet.toArray(new UsageInfo[usagesSet.size()]));
prepareSuccessful();
return true;
}
示例6: preprocessUsages
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
final UsageInfo[] usagesIn = refUsages.get();
ArrayList<UsageInfo> oldUsages = new ArrayList<UsageInfo>();
addAll(oldUsages, usagesIn);
final ObjectUpcastedUsageInfo[] objectUpcastedUsageInfos = objectUpcastedUsages(usagesIn);
if (myPrepareSuccessfulSwingThreadCallback != null) {
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
if (objectUpcastedUsageInfos.length > 0) {
final String message = RefactoringBundle.message("instances.of.0.upcasted.to.1.were.found",
RefactoringUIUtil.getDescription(myClass, true), CommonRefactoringUtil.htmlEmphasize(
CommonClassNames.JAVA_LANG_OBJECT));
conflicts.putValue(myClass, message);
}
analyzeConflicts(usagesIn, conflicts);
if (!conflicts.isEmpty()) {
ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, usagesIn);
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
if (objectUpcastedUsageInfos.length > 0) {
showObjectUpcastedUsageView(objectUpcastedUsageInfos);
setPreviewUsages(true);
}
}
ArrayList<UsageInfo> filteredUsages = filterUsages(oldUsages);
refUsages.set(filteredUsages.toArray(new UsageInfo[filteredUsages.size()]));
prepareSuccessful();
return true;
}
示例7: preprocessUsages
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
@Override
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
MultiMap<PsiElement, String> conflictDescriptions = new MultiMap<PsiElement, String>();
for (ChangeSignatureUsageProcessor usageProcessor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) {
final MultiMap<PsiElement, String> conflicts = usageProcessor.findConflicts(myChangeInfo, refUsages);
for (PsiElement key : conflicts.keySet()) {
Collection<String> collection = conflictDescriptions.get(key);
if (collection.isEmpty()) collection = new HashSet<String>();
collection.addAll(conflicts.get(key));
conflictDescriptions.put(key, collection);
}
}
final UsageInfo[] usagesIn = refUsages.get();
RenameUtil.addConflictDescriptions(usagesIn, conflictDescriptions);
Set<UsageInfo> usagesSet = new HashSet<UsageInfo>(Arrays.asList(usagesIn));
RenameUtil.removeConflictUsages(usagesSet);
if (!conflictDescriptions.isEmpty()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new ConflictsInTestsException(conflictDescriptions.values());
}
ConflictsDialog dialog = prepareConflictsDialog(conflictDescriptions, usagesIn);
if (!dialog.showAndGet()) {
if (dialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
refUsages.set(usagesSet.toArray(new UsageInfo[usagesSet.size()]));
prepareSuccessful();
return true;
}
示例8: processIntention
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
@Override
protected final void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
final PsiMember member = (PsiMember)element.getParent();
final PsiModifierList modifierList = member.getModifierList();
if (modifierList == null) {
return;
}
final MultiMap<PsiElement, String> conflicts = checkForConflicts(member);
final Project project = member.getProject();
final boolean conflictsDialogOK;
if (conflicts.isEmpty()) {
conflictsDialogOK = true;
} else {
final ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts, new Runnable() {
@Override
public void run() {
final AccessToken token = start();
try {
modifierList.setModifierProperty(getModifier(), true);
}
finally {
token.finish();
}
}
});
conflictsDialogOK = conflictsDialog.showAndGet();
}
if (conflictsDialogOK) {
modifierList.setModifierProperty(getModifier(), true);
final PsiElement whitespace = PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText(" ");
final PsiElement sibling = modifierList.getNextSibling();
if (sibling instanceof PsiWhiteSpace) {
sibling.replace(whitespace);
CodeStyleManager.getInstance(project).reformatRange(member, modifierList.getTextOffset(),
modifierList.getNextSibling().getTextOffset());
}
}
}
示例9: doOKAction
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected void doOKAction()
{
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
if(myCreateInnerClassRb.isSelected())
{
final PsiClass innerClass = myTargetClass.findInnerClassByName(myInnerClassName.getText(), false);
if(innerClass != null)
{
conflicts.putValue(innerClass, "Inner class " + myInnerClassName.getText() + " already defined in class " + myTargetClass.getName());
}
}
if(conflicts.size() > 0)
{
final ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
if(!conflictsDialog.showAndGet())
{
if(conflictsDialog.isShowConflicts())
{
close(CANCEL_EXIT_CODE);
}
return;
}
}
final JCheckBox makeVarargsCb = myCreateInnerClassRb.isSelected() ? myCbMakeVarargs : myCbMakeVarargsAnonymous;
if(makeVarargsCb != null && makeVarargsCb.isSelected())
{
final VariableData data = myInputVariables[myInputVariables.length - 1];
if(data.type instanceof PsiArrayType)
{
data.type = new PsiEllipsisType(((PsiArrayType) data.type).getComponentType());
}
}
super.doOKAction();
}
示例10: doOKAction
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
protected void doOKAction()
{
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
checkMethodConflicts(conflicts);
if(!conflicts.isEmpty())
{
final ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
if(!conflictsDialog.showAndGet())
{
if(conflictsDialog.isShowConflicts())
{
close(CANCEL_EXIT_CODE);
}
return;
}
}
if(myMakeVarargs != null && myMakeVarargs.isSelected())
{
final VariableData data = myInputVariables[myInputVariables.length - 1];
if(data.type instanceof PsiArrayType)
{
data.type = new PsiEllipsisType(((PsiArrayType) data.type).getComponentType());
}
}
final PsiMethod containingMethod = getContainingMethod();
if(containingMethod != null && containingMethod.hasModifierProperty(PsiModifier.PUBLIC))
{
PropertiesComponent.getInstance(myProject).setValue(EXTRACT_METHOD_DEFAULT_VISIBILITY, getVisibility());
}
if(myGenerateAnnotations != null && myGenerateAnnotations.isEnabled())
{
PropertiesComponent.getInstance(myProject).setValue(EXTRACT_METHOD_GENERATE_ANNOTATIONS, myGenerateAnnotations.isSelected(), true);
}
super.doOKAction();
}
示例11: doRearrangePackage
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
public static void doRearrangePackage(final Project project, final PsiDirectory[] directories) {
if (!CommonRefactoringUtil.checkReadOnlyStatusRecursively(project, Arrays.asList(directories), true)) {
return;
}
List<PsiDirectory> sourceRootDirectories = buildRearrangeTargetsList(project, directories);
DirectoryChooser chooser = new DirectoryChooser(project);
chooser.setTitle(RefactoringBundle.message("select.source.root.chooser.title"));
chooser.fillList(sourceRootDirectories.toArray(new PsiDirectory[sourceRootDirectories.size()]), null, project, "");
if (!chooser.showAndGet()) {
return;
}
final PsiDirectory selectedTarget = chooser.getSelectedDirectory();
if (selectedTarget == null) return;
final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
final Runnable analyzeConflicts = new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
RefactoringConflictsUtil
.analyzeModuleConflicts(project, Arrays.asList(directories), UsageInfo.EMPTY_ARRAY, selectedTarget, conflicts);
}
});
}
};
if (!ProgressManager.getInstance()
.runProcessWithProgressSynchronously(analyzeConflicts, "Analyze Module Conflicts...", true, project)) {
return;
}
if (!conflicts.isEmpty()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new BaseRefactoringProcessor.ConflictsInTestsException(conflicts.values());
}
else {
final ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
if (!conflictsDialog.showAndGet()) {
return;
}
}
}
final Ref<IncorrectOperationException> ex = Ref.create(null);
final String commandDescription = RefactoringBundle.message("moving.directories.command");
Runnable runnable = new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
LocalHistoryAction a = LocalHistory.getInstance().startAction(commandDescription);
try {
rearrangeDirectoriesToTarget(directories, selectedTarget);
}
catch (IncorrectOperationException e) {
ex.set(e);
}
finally {
a.finish();
}
}
});
}
};
CommandProcessor.getInstance().executeCommand(project, runnable, commandDescription, null);
if (ex.get() != null) {
RefactoringUIUtil.processIncorrectOperation(project, ex.get());
}
}
示例12: preprocessUsages
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
@Override
public boolean preprocessUsages(@NotNull final Ref<UsageInfo[]> refUsages) {
UsageInfo[] usagesIn = refUsages.get();
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
RenameUtil.addConflictDescriptions(usagesIn, conflicts);
RenamePsiElementProcessor.forElement(myPrimaryElement).findExistingNameConflicts(myPrimaryElement, myNewName, conflicts, myAllRenames);
if (!conflicts.isEmpty()) {
final RefactoringEventData conflictData = new RefactoringEventData();
conflictData.putUserData(RefactoringEventData.CONFLICTS_KEY, conflicts.values());
myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
.conflictsDetected("refactoring.rename", conflictData);
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new ConflictsInTestsException(conflicts.values());
}
ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, refUsages.get());
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
final List<UsageInfo> variableUsages = new ArrayList<UsageInfo>();
if (!myRenamers.isEmpty()) {
if (!findRenamedVariables(variableUsages)) return false;
final LinkedHashMap<PsiElement, String> renames = new LinkedHashMap<PsiElement, String>();
for (final AutomaticRenamer renamer : myRenamers) {
final List<? extends PsiNamedElement> variables = renamer.getElements();
for (final PsiNamedElement variable : variables) {
final String newName = renamer.getNewName(variable);
if (newName != null) {
addElement(variable, newName);
prepareRenaming(variable, newName, renames);
}
}
}
if (!renames.isEmpty()) {
for (PsiElement element : renames.keySet()) {
assertNonCompileElement(element);
}
myAllRenames.putAll(renames);
final Runnable runnable = new Runnable() {
@Override
public void run() {
for (final Map.Entry<PsiElement, String> entry : renames.entrySet()) {
final UsageInfo[] usages =
ApplicationManager.getApplication().runReadAction(new Computable<UsageInfo[]>() {
@Override
public UsageInfo[] compute() {
return RenameUtil.findUsages(entry.getKey(), entry.getValue(), mySearchInComments, mySearchTextOccurrences, myAllRenames);
}
});
Collections.addAll(variableUsages, usages);
}
}
};
if (!ProgressManager.getInstance()
.runProcessWithProgressSynchronously(runnable, RefactoringBundle.message("searching.for.variables"), true, myProject)) {
return false;
}
}
}
final Set<UsageInfo> usagesSet = ContainerUtil.newLinkedHashSet(usagesIn);
usagesSet.addAll(variableUsages);
final List<UnresolvableCollisionUsageInfo> conflictUsages = RenameUtil.removeConflictUsages(usagesSet);
if (conflictUsages != null) {
mySkippedUsages.addAll(conflictUsages);
}
refUsages.set(usagesSet.toArray(new UsageInfo[usagesSet.size()]));
prepareSuccessful();
return PsiElementRenameHandler.canRename(myProject, null, myPrimaryElement);
}
示例13: reportConflicts
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
private static boolean reportConflicts(final MultiMap<PsiElement, String> conflicts, final Project project) {
if (conflicts.isEmpty()) return true;
ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
return conflictsDialog.showAndGet();
}
示例14: reportConflicts
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
private static boolean reportConflicts(final ArrayList<String> conflicts, final Project project) {
ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
return conflictsDialog.showAndGet();
}
示例15: reportConflicts
import com.intellij.refactoring.ui.ConflictsDialog; //导入方法依赖的package包/类
private static boolean reportConflicts(final MultiMap<PsiElement, String> conflicts, final Project project) {
ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
return conflictsDialog.showAndGet();
}