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


Java MultiMap.isEmpty方法代码示例

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


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

示例1: getConflictMessage

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
@Override
public String getConflictMessage() {
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  final PsiElement element = getElement();
  if (element instanceof PsiMethodCallExpression) {
    PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)element;
    final PsiMethod superConstructor = methodCallExpression.resolveMethod();
    if (superConstructor != null) {
      InlineMethodProcessor.addInaccessibleMemberConflicts(superConstructor, new UsageInfo[]{new UsageInfo(methodCallExpression.getMethodExpression())}, new ReferencedElementsCollector(){
        @Override
        protected void checkAddMember(@NotNull PsiMember member) {
          if (!PsiTreeUtil.isAncestor(superConstructor.getContainingClass(), member, false)) {
            super.checkAddMember(member);
          }
        }
      }, conflicts);
      if (InlineMethodProcessor.checkBadReturns(superConstructor) && !InlineUtil.allUsagesAreTailCalls(superConstructor)) {
        conflicts.putValue(superConstructor, CommonRefactoringUtil.capitalize(RefactoringBundle.message("refactoring.is.not.supported.when.return.statement.interrupts.the.execution.flow", "") + " of super constructor"));
      }
    }
  }
  return conflicts.isEmpty() ? null : conflicts.values().iterator().next(); //todo
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InlineSuperCallUsageInfo.java

示例2: processMethods

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
public boolean processMethods(PsiScopeProcessor processor, @NotNull ResolveState state, PsiType qualifierType, Project project) {
  if (qualifierType == null) return true;

  NameHint nameHint = processor.getHint(NameHint.KEY);
  String name = nameHint == null ? null : nameHint.getName(state);
  final MultiMap<String, PsiMethod> map = name != null ? myOriginalMethodsByNameAndType.get(name) : myOriginalMethodByType.getValue();
  if (map.isEmpty()) {
    return true;
  }

  for (String superType : ResolveUtil.getAllSuperTypes(qualifierType, project)) {
    for (PsiMethod method : map.get(superType)) {
      String info = GdkMethodUtil.generateOriginInfo(method);
      GrGdkMethod gdk = GrGdkMethodImpl.createGdkMethod(method, myStatic, info);
      if (!processor.execute(gdk, state)) {
        return false;
      }
    }
  }

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

示例3: isOKTest

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
/**
 * Use for validator tests
 */
public String isOKTest(String varName, boolean allOccurences) {
  MultiMap<PsiElement, String> list = isOKImpl(varName, allOccurences);
  String result = "";
  final String[] strings = ArrayUtil.toStringArray((Collection<String>)list.values());
  Arrays.sort(strings, new Comparator<String>() {
    @Override
    public int compare(String o1, String o2) {
      return o1.compareTo(o2);
    }
  });

  for (String s : strings) {
    result = result + s.replaceAll("<b><code>", "").replaceAll("</code></b>", "") + "\n";
  }
  if (!list.isEmpty()) {
    result = result.substring(0, result.length() - 1);
  }
  if (result.isEmpty()) {
    result = "ok";
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GrIntroduceValidatorEngine.java

示例4: processUnderFile

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
private void processUnderFile(VirtualFile file) {
  final MultiMap<VirtualFile, FileAnnotation> annotations = new MultiMap<VirtualFile, FileAnnotation>();
  synchronized (myLock) {
    for (VirtualFile virtualFile : myFileAnnotationMap.keySet()) {
      if (VfsUtilCore.isAncestor(file, virtualFile, true)) {
        final Collection<FileAnnotation> values = myFileAnnotationMap.get(virtualFile);
        for (FileAnnotation value : values) {
          annotations.putValue(virtualFile, value);
        }
      }
    }
  }
  if (! annotations.isEmpty()) {
    for (Map.Entry<VirtualFile, Collection<FileAnnotation>> entry : annotations.entrySet()) {
      final VirtualFile key = entry.getKey();
      final VcsRevisionNumber number = fromDiffProvider(key);
      if (number == null) continue;
      final Collection<FileAnnotation> fileAnnotations = entry.getValue();
      for (FileAnnotation annotation : fileAnnotations) {
        if (annotation.isBaseRevisionChanged(number)) {
          annotation.close();
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:VcsAnnotationLocalChangesListenerImpl.java

示例5: 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

示例6: processIntention

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

示例7: preprocessUsages

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
protected boolean preprocessUsages(@NotNull final Ref<UsageInfo[]> refUsages) {
  MultiMap<PsiElement, String> conflicts = getConflicts(refUsages.get());
  if (!conflicts.isEmpty()) {
    return showConflicts(conflicts, refUsages.get());
  }
  return super.preprocessUsages(refUsages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:InlineToAnonymousClassProcessor.java

示例8: 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

示例9: doOKAction

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

示例10: preprocessUsages

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
  UsageInfo[] usagesIn = refUsages.get();
  MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();

  AnySameNameVariables anySameNameVariables = new AnySameNameVariables();
  myMethodToReplaceIn.accept(anySameNameVariables);
  final Pair<PsiElement, String> conflictPair = anySameNameVariables.getConflict();
  if (conflictPair != null) {
    conflicts.putValue(conflictPair.first, conflictPair.second);
  }

  if (!myGenerateDelegate) {
    detectAccessibilityConflicts(usagesIn, conflicts);
  }

  if (myParameterInitializer != null && !myMethodToReplaceIn.hasModifierProperty(PsiModifier.PRIVATE)) {
    final AnySupers anySupers = new AnySupers();
    myParameterInitializer.accept(anySupers);
    if (anySupers.isResult()) {
      for (UsageInfo usageInfo : usagesIn) {
        if (!(usageInfo.getElement() instanceof PsiMethod) && !(usageInfo instanceof InternalUsageInfo)) {
          if (!PsiTreeUtil.isAncestor(myMethodToReplaceIn.getContainingClass(), usageInfo.getElement(), false)) {
            String message = RefactoringBundle.message("parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class",
                                                       CommonRefactoringUtil.htmlEmphasize(PsiKeyword.SUPER));
            conflicts.putValue(myParameterInitializer, message);
            break;
          }
        }
      }
    }
  }

  for (IntroduceParameterMethodUsagesProcessor processor : IntroduceParameterMethodUsagesProcessor.EP_NAME.getExtensions()) {
    processor.findConflicts(this, refUsages.get(), conflicts);
  }

  myHasConflicts = !conflicts.isEmpty();
  return showConflicts(conflicts, usagesIn);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:IntroduceParameterProcessor.java

示例11: preprocessUsages

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

示例12: checkConflicts

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
@Override
public boolean checkConflicts(final PullUpDialog dialog) {
  final List<MemberInfo> infos = dialog.getSelectedMemberInfos();
  final MemberInfo[] memberInfos = infos.toArray(new MemberInfo[infos.size()]);
  final PsiClass superClass = dialog.getSuperClass();
  if (!checkWritable(superClass, memberInfos)) return false;
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          final PsiDirectory targetDirectory = superClass.getContainingFile().getContainingDirectory();
          final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null;
          conflicts
            .putAllValues(PullUpConflictsUtil.checkConflicts(memberInfos, mySubclass, superClass, targetPackage, targetDirectory, dialog.getContainmentVerifier()));
        }
      });

    }
  }, RefactoringBundle.message("detecting.possible.conflicts"), true, myProject)) return false;
  if (!conflicts.isEmpty()) {
    ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
    conflictsDialog.show();
    final boolean ok = conflictsDialog.isOK();
    if (!ok && conflictsDialog.isShowConflicts()) dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
    return ok;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:JavaPullUpHandler.java

示例13: 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

示例14: preprocessUsages

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
@Override
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  myDelegate.findConflicts(refUsages.get(), conflicts);
  
  if (!conflicts.isEmpty())  {
    return showConflicts(conflicts, null);
  }

  if (myRenameProcessor == null || myRenameProcessor.preprocessUsages(refUsages)) {
    prepareSuccessful();
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:InvertBooleanProcessor.java

示例15: invoke

import com.intellij.util.containers.MultiMap; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
  if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return;
  if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
    return;
  }
  EditorUtil.fillVirtualSpaceUntilCaret(editor);

  PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
  int offset = editor.getCaretModel().getOffset();
  List<TemplateImpl> applicableTemplates = TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(editor, file, false);

  Map<TemplateImpl, String> matchingTemplates = filterTemplatesByPrefix(applicableTemplates, editor, offset, false, true);
  MultiMap<String, CustomLiveTemplateLookupElement> customTemplatesLookupElements = getCustomTemplatesLookupItems(editor, file, offset);

  if (matchingTemplates.isEmpty()) {
    for (TemplateImpl template : applicableTemplates) {
      matchingTemplates.put(template, null);
    }
  }

  if (matchingTemplates.isEmpty() && customTemplatesLookupElements.isEmpty()) {
    HintManager.getInstance().showErrorHint(editor, CodeInsightBundle.message("templates.no.defined"));
    return;
  }

  showTemplatesLookup(project, editor, file, matchingTemplates, customTemplatesLookupElements);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ListTemplatesHandler.java


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