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


Java MultiMap.values方法代码示例

本文整理汇总了Java中com.intellij.util.containers.MultiMap.values方法的典型用法代码示例。如果您正苦于以下问题:Java MultiMap.values方法的具体用法?Java MultiMap.values怎么用?Java MultiMap.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.containers.MultiMap的用法示例。


在下文中一共展示了MultiMap.values方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
public List<AbstractFilePatchInProgress> execute(@NotNull final List<? extends FilePatch> list) {
  final PatchBaseDirectoryDetector directoryDetector = PatchBaseDirectoryDetector.getInstance(myProject);

  final List<PatchAndVariants> candidates = new ArrayList<PatchAndVariants>(list.size());
  final List<FilePatch> newOrWithoutMatches = new ArrayList<FilePatch>();
  findCandidates(list, directoryDetector, candidates, newOrWithoutMatches);

  final MultiMap<VirtualFile, AbstractFilePatchInProgress> result = new MultiMap<VirtualFile, AbstractFilePatchInProgress>();
  // process exact matches: if one, leave and extract. if several - leave only them
  filterExactMatches(candidates, result);

  // partially check by context
  selectByContextOrByStrip(candidates, result); // for text only
  // created or no variants
  workWithNotExisting(directoryDetector, newOrWithoutMatches, result);
  return new ArrayList<AbstractFilePatchInProgress>(result.values());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MatchPatchPaths.java

示例2: ConflictsDialog

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
public ConflictsDialog(@NotNull Project project,
                       @NotNull MultiMap<PsiElement, String> conflictDescriptions,
                       @Nullable Runnable doRefactoringRunnable,
                       boolean alwaysShowOkButton,
                       boolean canShowConflictsInView) {
  super(project, true);
  myProject = project;
  myDoRefactoringRunnable = doRefactoringRunnable;
  myCanShowConflictsInView = canShowConflictsInView;
  final LinkedHashSet<String> conflicts = new LinkedHashSet<String>();

  for (String conflict : conflictDescriptions.values()) {
    conflicts.add(conflict);
  }
  myConflictDescriptions = ArrayUtil.toStringArray(conflicts);
  myElementConflictDescription = conflictDescriptions;
  setTitle(RefactoringBundle.message("problems.detected.title"));
  setOKButtonText(RefactoringBundle.message("continue.button"));
  setOKActionEnabled(alwaysShowOkButton || getDoRefactoringRunnable(null) != null);
  init();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ConflictsDialog.java

示例3: showConflicts

import com.intellij.util.containers.MultiMap; //导入方法依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:BaseRefactoringProcessor.java

示例4: processDynamicElements

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
@Override
public void processDynamicElements(@NotNull PsiType qualifierType,
                                   PsiClass aClass,
                                   @NotNull PsiScopeProcessor processor,
                                   @NotNull PsiElement place,
                                   @NotNull ResolveState state) {
  ClassHint classHint = processor.getHint(ClassHint.KEY);
  if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return;

  MultiMap<String, PsiMethod> methodMap = aClass.getUserData(KEY);
  if (methodMap == null) {
    MyBuilder builder = new MyBuilder(aClass);
    builder.generateMethods();
    methodMap = ((UserDataHolderEx)aClass).putUserDataIfAbsent(KEY, builder.myResult);
  }

  String nameHint = ResolveUtil.getNameHint(processor);

  Collection<? extends PsiMethod> methods = nameHint == null ? methodMap.values() : methodMap.get(nameHint);

  for (PsiMethod method : methods) {
    if (!processor.execute(method, state)) return;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SwingBuilderNonCodeMemberContributor.java

示例5: preprocessUsages

import com.intellij.util.containers.MultiMap; //导入方法依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:ChangeSignatureProcessor.java

示例6: doTest

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
private void doTest(final String... conflicts) throws Exception {
  final MultiMap<PsiElement, String> conflictsMap = new MultiMap<>();
  doTest((rootDir, rootAfter) -> {
    final PsiClass srcClass = myJavaFacade.findClass("a.A", GlobalSearchScope.allScope(myProject));
    assertTrue("Source class not found", srcClass != null);

    final PsiClass targetClass = myJavaFacade.findClass("b.B", GlobalSearchScope.allScope(myProject));
    assertTrue("Target class not found", targetClass != null);

    final PsiMethod[] methods = srcClass.getMethods();
    assertTrue("No methods found", methods.length > 0);
    final MemberInfo[] membersToMove = new MemberInfo[1];
    final MemberInfo memberInfo = new MemberInfo(methods[0]);
    memberInfo.setChecked(true);
    membersToMove[0] = memberInfo;

    final PsiDirectory targetDirectory = targetClass.getContainingFile().getContainingDirectory();
    final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null;
    conflictsMap.putAllValues(
      PullUpConflictsUtil.checkConflicts(membersToMove, srcClass, targetClass, targetPackage, targetDirectory,
                                         psiMethod -> PullUpProcessor.checkedInterfacesContain(Arrays.asList(membersToMove), psiMethod)));

    new PullUpProcessor(srcClass, targetClass, membersToMove, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
  });

  if (conflicts.length != 0 && conflictsMap.isEmpty()) {
    fail("Conflict was not detected");
  }
  final HashSet<String> values = new HashSet<>(conflictsMap.values());
  final HashSet<String> expected = new HashSet<>(Arrays.asList(conflicts));

  assertEquals(expected.size(), values.size());
  for (String value : values) {
    if (!expected.contains(value)) {
      fail("Conflict: " + value + " is unexpectedly reported");
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:PullUpMultifileTest.java

示例7: createSteps

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
@Nullable
@Override
protected StepSequence createSteps(@NotNull WizardContext context, @NotNull ModulesProvider modulesProvider) {
  MultiMap<TemplatesGroup, ProjectTemplate> map = getTemplatesMap(context);
  StepSequence sequence = new StepSequence();
  for (ProjectTemplate template : map.values()) {
    sequence.addStepsForBuilder(template.createModuleBuilder(), context, modulesProvider);
  }
  mySelectTemplateStep = new SelectTemplateStep(context, sequence, map);
  sequence.addCommonStep(mySelectTemplateStep);
  return sequence;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CreateFromTemplateMode.java

示例8: pathsFromGroups

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
public static Set<String> pathsFromGroups(MultiMap<VirtualFile, AbstractFilePatchInProgress> patchGroups) {
  final Set<String> selectedPaths = new HashSet<String>();
  final Collection<? extends AbstractFilePatchInProgress> values = patchGroups.values();
  for (AbstractFilePatchInProgress value : values) {
    final String path = value.getPatch().getBeforeName() == null ? value.getPatch().getAfterName() : value.getPatch().getBeforeName();
    selectedPaths.add(path);
  }
  return selectedPaths;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ApplyPatchDefaultExecutor.java

示例9: GdkMethodHolder

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
private GdkMethodHolder(final PsiClass categoryClass, final boolean isStatic, final GlobalSearchScope scope) {
  myStatic = isStatic;
  myScope = scope;
  final MultiMap<String, PsiMethod> byName = new MultiMap<String, PsiMethod>();
  myPsiManager = categoryClass.getManager();
  for (PsiMethod m : categoryClass.getMethods()) {
    final PsiParameter[] params = m.getParameterList().getParameters();
    if (params.length == 0) continue;
    if (PsiUtil.isDGMMethod(m) && (PsiImplUtil.isDeprecatedByAnnotation(m) || PsiImplUtil.isDeprecatedByDocTag(m))) {
      continue;
    }
    byName.putValue(m.getName(), m);
  }
  this.myOriginalMethodByType = new VolatileNotNullLazyValue<MultiMap<String, PsiMethod>>() {
    @NotNull
    @Override
    protected MultiMap<String, PsiMethod> compute() {
      MultiMap<String, PsiMethod> map = new MultiMap<String, PsiMethod>();
      for (PsiMethod method : byName.values()) {
        if (!method.hasModifierProperty(PsiModifier.PUBLIC)) continue;
        map.putValue(getCategoryTargetType(method).getCanonicalText(), method);
      }
      return map;
    }
  };

  myOriginalMethodsByNameAndType = new ConcurrentFactoryMap<String, MultiMap<String, PsiMethod>>() {
    @Override
    protected MultiMap<String, PsiMethod> create(String name) {
      MultiMap<String, PsiMethod> map = new MultiMap<String, PsiMethod>();
      for (PsiMethod method : byName.get(name)) {
        map.putValue(getCategoryTargetType(method).getCanonicalText(), method);
      }
      return map;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:GdkMethodHolder.java

示例10: preprocessUsages

import com.intellij.util.containers.MultiMap; //导入方法依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:GrChangeSignatureProcessor.java

示例11: doRearrangePackage

import com.intellij.util.containers.MultiMap; //导入方法依赖的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());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:70,代码来源:MoveClassesOrPackagesImpl.java

示例12: doTest

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
private void doTest(MemberInfo[] members,
                    @NonNls String newClassName,
                    String targetPackageName,
                    VirtualFile rootDir,
                    PsiClass psiClass,
                    String[] conflicts) throws IOException {
  PsiDirectory targetDirectory;
  if (targetPackageName == null) {
    targetDirectory = psiClass.getContainingFile().getContainingDirectory();
  } else {
    final PsiPackage aPackage = myJavaFacade.findPackage(targetPackageName);
    assertNotNull(aPackage);
    targetDirectory = aPackage.getDirectories()[0];
  }
  ExtractSuperClassProcessor processor = new ExtractSuperClassProcessor(myProject,
                                                                        targetDirectory,
                                                                        newClassName,
                                                                        psiClass, members,
                                                                        false,
                                                                        new DocCommentPolicy<>(DocCommentPolicy.ASIS));
  final PsiPackage targetPackage;
  if (targetDirectory != null) {
    targetPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory);
  }
  else {
    targetPackage = null;
  }
  final PsiClass superClass = psiClass.getExtendsListTypes().length > 0 ? psiClass.getSuperClass() : null;
  final MultiMap<PsiElement, String> conflictsMap =
    PullUpConflictsUtil.checkConflicts(members, psiClass, superClass, targetPackage, targetDirectory,
                                       psiMethod -> PullUpProcessor.checkedInterfacesContain(Arrays.asList(members), psiMethod), false);
  if (conflicts != null) {
    if (conflictsMap.isEmpty()) {
      fail("Conflicts were not detected");
    }
    final HashSet<String> expectedConflicts = new HashSet<>(Arrays.asList(conflicts));
    final HashSet<String> actualConflicts = new HashSet<>(conflictsMap.values());
    assertEquals(expectedConflicts.size(), actualConflicts.size());
    for (String actualConflict : actualConflicts) {
      if (!expectedConflicts.contains(actualConflict)) {
        fail("Unexpected conflict: " + actualConflict);
      }
    }
  } else if (!conflictsMap.isEmpty()) {
    fail("Unexpected conflicts!!!");
  }
  processor.run();
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  FileDocumentManager.getInstance().saveAllDocuments();

  String rootAfter = getRoot() + "/after";
  VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
  myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
  IdeaTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:ExtractSuperClassTest.java

示例13: processGlobalRequestsOptimized

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
private boolean processGlobalRequestsOptimized(@NotNull MultiMap<Set<IdIndexEntry>, RequestWithProcessor> singles,
                                               @NotNull ProgressIndicator progress,
                                               @NotNull final Map<RequestWithProcessor, Processor<PsiElement>> localProcessors) {
  if (singles.isEmpty()) {
    return true;
  }

  if (singles.size() == 1) {
    final Collection<? extends RequestWithProcessor> requests = singles.values();
    if (requests.size() == 1) {
      final RequestWithProcessor theOnly = requests.iterator().next();
      return processSingleRequest(theOnly.request, theOnly.refProcessor);
    }
  }

  progress.pushState();
  progress.setText(PsiBundle.message("psi.scanning.files.progress"));
  boolean result;

  try {
    // intersectionCandidateFiles holds files containing words from all requests in `singles` and words in corresponding container names
    final MultiMap<VirtualFile, RequestWithProcessor> intersectionCandidateFiles = createMultiMap();
    // restCandidateFiles holds files containing words from all requests in `singles` but EXCLUDING words in corresponding container names
    final MultiMap<VirtualFile, RequestWithProcessor> restCandidateFiles = createMultiMap();
    collectFiles(singles, progress, intersectionCandidateFiles, restCandidateFiles);

    if (intersectionCandidateFiles.isEmpty() && restCandidateFiles.isEmpty()) {
      return true;
    }

    final Set<String> allWords = new TreeSet<String>();
    for (RequestWithProcessor singleRequest : localProcessors.keySet()) {
      allWords.add(singleRequest.request.word);
    }
    progress.setText(PsiBundle.message("psi.search.for.word.progress", getPresentableWordsDescription(allWords)));

    if (intersectionCandidateFiles.isEmpty()) {
      result = processCandidates(localProcessors, restCandidateFiles, progress, restCandidateFiles.size(), 0);
    }
    else {
      int totalSize = restCandidateFiles.size() + intersectionCandidateFiles.size();
      result = processCandidates(localProcessors, intersectionCandidateFiles, progress, totalSize, 0);
      if (result) {
        result = processCandidates(localProcessors, restCandidateFiles, progress, totalSize, intersectionCandidateFiles.size());
      }
    }
  }
  finally {
    progress.popState();
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:PsiSearchHelperImpl.java

示例14: preprocessUsages

import com.intellij.util.containers.MultiMap; //导入方法依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:77,代码来源:RenameProcessor.java

示例15: findConflicts

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
private static boolean findConflicts(InitialInfo info) {
  //new ConflictsDialog()
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();

  final PsiElement declarationOwner = info.getContext().getParent();

  GroovyRecursiveElementVisitor visitor = new GroovyRecursiveElementVisitor() {
    @Override
    public void visitReferenceExpression(GrReferenceExpression referenceExpression) {
      super.visitReferenceExpression(referenceExpression);

      GroovyResolveResult resolveResult = referenceExpression.advancedResolve();
      PsiElement resolveContext = resolveResult.getCurrentFileResolveContext();
      if (resolveContext != null &&
          !(resolveContext instanceof GrImportStatement) &&
          !PsiTreeUtil.isAncestor(declarationOwner, resolveContext, true) && !skipResult(resolveResult)) {
        conflicts.putValue(referenceExpression, GroovyRefactoringBundle
          .message("ref.0.will.not.be.resolved.outside.of.current.context", referenceExpression.getText()));
      }
    }

    //skip 'print' and 'println'
    private boolean skipResult(GroovyResolveResult result) {
      PsiElement element = result.getElement();
      if (element instanceof PsiMethod) {
        String name = ((PsiMethod)element).getName();
        if (!name.startsWith("print")) return false;

        if (element instanceof GrGdkMethod) element = ((GrGdkMethod)element).getStaticMethod();

        PsiClass aClass = ((PsiMethod)element).getContainingClass();
        if (aClass != null) {
          String qname = aClass.getQualifiedName();
          return GroovyCommonClassNames.DEFAULT_GROOVY_METHODS.equals(qname);
        }
      }
      return false;
    }
  };

  GrStatement[] statements = info.getStatements();
  for (GrStatement statement : statements) {
    statement.accept(visitor);
  }

  if (conflicts.isEmpty()) return false;

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    throw new BaseRefactoringProcessor.ConflictsInTestsException(conflicts.values());
  }

  ConflictsDialog dialog = new ConflictsDialog(info.getProject(), conflicts);
  dialog.show();
  return !dialog.isOK();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:GroovyExtractMethodHandler.java


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