Java 类com.intellij.util.containers.MostlySingularMultiMap 实例源码

项目:intellij-ce-playground    文件:BaseExternalAnnotationsManager.java   
@NotNull
private List<AnnotationData> doCollect(@NotNull PsiModifierListOwner listOwner, boolean onlyWritable) {
  String externalName = getExternalName(listOwner, false);
  if (externalName == null) return NO_DATA;

  List<PsiFile> files = findExternalAnnotationsFiles(listOwner);
  if (files == null) return NO_DATA;

  SmartList<AnnotationData> result = new SmartList<AnnotationData>();
  for (PsiFile file : files) {
    if (!file.isValid()) continue;
    if (onlyWritable && !file.isWritable()) continue;

    MostlySingularMultiMap<String, AnnotationData> fileData = getDataFromFile(file);
    ContainerUtil.addAll(result, fileData.get(externalName));
  }
  if (result.isEmpty()) return NO_DATA;

  result.trimToSize();
  return result;
}
项目:intellij-ce-playground    文件:XmlPropertiesFileImpl.java   
private void ensurePropertiesLoaded() {
  while (myFileModificationStamp != myFile.getModificationStamp() || myPropertiesMap == null) {
    myFileModificationStamp = myFile.getModificationStamp();
    MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>();
    XmlTag rootTag = myFile.getRootTag();
    final List<IProperty> propertiesOrder = new ArrayList<IProperty>();
    if (rootTag != null) {
      XmlTag[] entries = rootTag.findSubTags("entry");
      for (XmlTag entry : entries) {
        XmlProperty property = new XmlProperty(entry, this);
        propertiesOrder.add(property);
        propertiesMap.add(property.getKey(), property);
      }
    }
    final boolean isAlphaSorted = PropertiesImplUtil.isAlphaSorted(propertiesOrder);
    myAlphaSorted = isAlphaSorted;
    myProperties = propertiesOrder;
    myPropertiesMap = propertiesMap;
  }
}
项目:intellij-ce-playground    文件:PropertiesFileImpl.java   
private void ensurePropertiesLoaded() {
  if (myPropertiesMap != null) return;

  final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES);
  MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>();
  List<IProperty> properties = new ArrayList<IProperty>(props.length);
  for (final ASTNode prop : props) {
    final Property property = (Property)prop.getPsi();
    String key = property.getUnescapedKey();
    propertiesMap.add(key, property);
    properties.add(property);
  }
  final boolean isAlphaSorted = PropertiesImplUtil.isAlphaSorted(properties);
  synchronized (lock) {
    if (myPropertiesMap != null) return;
    myProperties = properties;
    myPropertiesMap = propertiesMap;
    myAlphaSorted = isAlphaSorted;
  }
}
项目:tools-idea    文件:HighlightMethodUtil.java   
@Nullable
static HighlightInfo checkDuplicateMethod(PsiClass aClass,
                                          @NotNull PsiMethod method,
                                          @NotNull MostlySingularMultiMap<MethodSignature, PsiMethod> duplicateMethods) {
  if (aClass == null || method instanceof ExternallyDefinedPsiElement) return null;
  MethodSignature methodSignature = method.getSignature(PsiSubstitutor.EMPTY);
  int methodCount = 1;
  List<PsiMethod> methods = (List<PsiMethod>)duplicateMethods.get(methodSignature);
  if (methods.size() > 1) {
    methodCount++;
  }

  if (methodCount == 1 && aClass.isEnum() &&
      GenericsHighlightUtil.isEnumSyntheticMethod(methodSignature, aClass.getProject())) {
    methodCount++;
  }
  if (methodCount > 1) {
    String description = JavaErrorMessages.message("duplicate.method",
                                               JavaHighlightUtil.formatMethod(method),
                                               HighlightUtil.formatClass(aClass));
    TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
    return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
  }
  return null;
}
项目:tools-idea    文件:PropertiesFileImpl.java   
private void ensurePropertiesLoaded() {
  if (myPropertiesMap != null) return;

  final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES);
  MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>();
  List<IProperty> properties = new ArrayList<IProperty>(props.length);
  for (final ASTNode prop : props) {
    final Property property = (Property)prop.getPsi();
    String key = property.getUnescapedKey();
    propertiesMap.add(key, property);
    properties.add(property);
  }
  synchronized (lock) {
    if (myPropertiesMap != null) return;
    myProperties = properties;
    myPropertiesMap = propertiesMap;
  }
}
项目:consulo-java    文件:HighlightVisitorImpl.java   
@NotNull
private MostlySingularMultiMap<MethodSignature, PsiMethod> getDuplicateMethods(@NotNull PsiClass aClass)
{
    MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = myDuplicateMethods.get(aClass);
    if(signatures == null)
    {
        signatures = new MostlySingularMultiMap<>();
        for(PsiMethod method : aClass.getMethods())
        {
            if(method instanceof ExternallyDefinedPsiElement)
            {
                continue; // ignore aspectj-weaved methods; they are checked elsewhere
            }
            MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
            signatures.add(signature, method);
        }

        myDuplicateMethods.put(aClass, signatures);
    }
    return signatures;
}
项目:intellij-ce-playground    文件:BaseExternalAnnotationsManager.java   
public MostlySingularMultiMap<String, AnnotationData> getResult() {
  if (myData.isEmpty()) {
    return MostlySingularMultiMap.emptyMap();
  }
  myData.compact();
  return myData;
}
项目:intellij-ce-playground    文件:PsiJavaFileBaseImpl.java   
@Override
public Result<MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext>> compute() {
  SymbolCollectingProcessor p = new SymbolCollectingProcessor();
  myFile.processDeclarationsNoGuess(p, ResolveState.initial(), myFile, myFile);
  MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext> results = p.getResults();
  return Result.create(results, PsiModificationTracker.MODIFICATION_COUNT, myFile);
}
项目:intellij-ce-playground    文件:HighlightMethodUtil.java   
@Nullable
static HighlightInfo checkDuplicateMethod(PsiClass aClass,
                                          @NotNull PsiMethod method,
                                          @NotNull MostlySingularMultiMap<MethodSignature, PsiMethod> duplicateMethods) {
  if (aClass == null || method instanceof ExternallyDefinedPsiElement) return null;
  MethodSignature methodSignature = method.getSignature(PsiSubstitutor.EMPTY);
  int methodCount = 1;
  List<PsiMethod> methods = (List<PsiMethod>)duplicateMethods.get(methodSignature);
  if (methods.size() > 1) {
    methodCount++;
  }

  if (methodCount == 1 && aClass.isEnum() &&
      GenericsHighlightUtil.isEnumSyntheticMethod(methodSignature, aClass.getProject())) {
    methodCount++;
  }
  if (methodCount > 1) {
    String description = JavaErrorMessages.message("duplicate.method",
                                               JavaHighlightUtil.formatMethod(method),
                                               HighlightUtil.formatClass(aClass));
    TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
    return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).
      range(method, textRange.getStartOffset(), textRange.getEndOffset()).
      descriptionAndTooltip(description).create();
  }
  return null;
}
项目:intellij-ce-playground    文件:HighlightVisitorImpl.java   
@NotNull
private MostlySingularMultiMap<MethodSignature, PsiMethod> getDuplicateMethods(@NotNull PsiClass aClass) {
  MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = myDuplicateMethods.get(aClass);
  if (signatures == null) {
    signatures = new MostlySingularMultiMap<MethodSignature, PsiMethod>();
    for (PsiMethod method : aClass.getMethods()) {
      if (method instanceof ExternallyDefinedPsiElement) continue; // ignore aspectj-weaved methods; they are checked elsewhere
      MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
      signatures.add(signature, method);
    }

    myDuplicateMethods.put(aClass, signatures);
  }
  return signatures;
}
项目:tools-idea    文件:PsiJavaFileBaseImpl.java   
@Override
public Result<MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext>> compute() {
  SymbolCollectingProcessor p = new SymbolCollectingProcessor();
  myFile.processDeclarationsNoGuess(p, ResolveState.initial(), myFile, myFile);
  MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext> results = p.getResults();
  return Result.create(results, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
}
项目:tools-idea    文件:HighlightVisitorImpl.java   
@NotNull
private MostlySingularMultiMap<MethodSignature, PsiMethod> getDuplicateMethods(PsiClass aClass) {
  MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = myDuplicateMethods.get(aClass);
  if (signatures == null) {
    signatures = new MostlySingularMultiMap<MethodSignature, PsiMethod>();
    for (PsiMethod method : aClass.getMethods()) {
      if (method instanceof ExternallyDefinedPsiElement) continue; // ignore aspectj-weaved methods; they are checked elsewhere
      MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
      signatures.add(signature, method);
    }

    myDuplicateMethods.put(aClass, signatures);
  }
  return signatures;
}
项目:consulo-java    文件:BaseExternalAnnotationsManager.java   
@NotNull
private List<AnnotationData> doCollect(@NotNull PsiModifierListOwner listOwner, boolean onlyWritable)
{
    String externalName = getExternalName(listOwner, false);
    if(externalName == null)
    {
        return NO_DATA;
    }

    List<PsiFile> files = findExternalAnnotationsFiles(listOwner);
    if(files == null)
    {
        return NO_DATA;
    }

    SmartList<AnnotationData> result = new SmartList<AnnotationData>();
    for(PsiFile file : files)
    {
        if(!file.isValid())
        {
            continue;
        }
        if(onlyWritable && !file.isWritable())
        {
            continue;
        }

        MostlySingularMultiMap<String, AnnotationData> fileData = getDataFromFile(file);
        ContainerUtil.addAll(result, fileData.get(externalName));
    }
    if(result.isEmpty())
    {
        return NO_DATA;
    }

    result.trimToSize();
    return result;
}
项目:consulo-java    文件:BaseExternalAnnotationsManager.java   
public MostlySingularMultiMap<String, AnnotationData> getResult()
{
    if(myData.isEmpty())
    {
        return MostlySingularMultiMap.emptyMap();
    }
    myData.compact();
    return myData;
}
项目:consulo-java    文件:PsiJavaFileBaseImpl.java   
@Override
public Result<MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext>> compute()
{
    SymbolCollectingProcessor p = new SymbolCollectingProcessor();
    myFile.processDeclarationsNoGuess(p, ResolveState.initial(), myFile, myFile);
    MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext> results = p.getResults();
    return Result.create(results, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
}
项目:consulo-java    文件:HighlightMethodUtil.java   
@Nullable
static HighlightInfo checkDuplicateMethod(PsiClass aClass, @NotNull PsiMethod method, @NotNull MostlySingularMultiMap<MethodSignature, PsiMethod> duplicateMethods)
{
    if(aClass == null || method instanceof ExternallyDefinedPsiElement)
    {
        return null;
    }
    MethodSignature methodSignature = method.getSignature(PsiSubstitutor.EMPTY);
    int methodCount = 1;
    List<PsiMethod> methods = (List<PsiMethod>) duplicateMethods.get(methodSignature);
    if(methods.size() > 1)
    {
        methodCount++;
    }

    if(methodCount == 1 && aClass.isEnum() && GenericsHighlightUtil.isEnumSyntheticMethod(methodSignature, aClass.getProject()))
    {
        methodCount++;
    }
    if(methodCount > 1)
    {
        String description = JavaErrorMessages.message("duplicate.method", JavaHighlightUtil.formatMethod(method), HighlightUtil.formatClass(aClass));
        TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
        return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).
                range(method, textRange.getStartOffset(), textRange.getEndOffset()).
                descriptionAndTooltip(description).create();
    }
    return null;
}
项目:intellij-ce-playground    文件:SymbolCollectingProcessor.java   
public MostlySingularMultiMap<String, ResultWithContext> getResults() {
  return myResult;
}
项目:tools-idea    文件:SymbolCollectingProcessor.java   
public MostlySingularMultiMap<String, ResultWithContext> getResults() {
  return myResult;
}
项目:consulo-java    文件:SymbolCollectingProcessor.java   
public MostlySingularMultiMap<String, ResultWithContext> getResults() {
  return myResult;
}