Java 类com.intellij.openapi.util.MultiValuesMap 实例源码

项目:intellij-ce-playground    文件:ArtifactBySourceFileFinderImpl.java   
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
  if (myFile2Artifacts == null) {
    myFile2Artifacts =
      CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
        public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
          MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
          List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
          trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
          for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
            ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
          }
          return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
        }
      }, false);
  }
  return myFile2Artifacts;
}
项目:intellij-ce-playground    文件:ArtifactBySourceFileFinderImpl.java   
private MultiValuesMap<VirtualFile, Artifact> computeFileToArtifactsMap() {
  final MultiValuesMap<VirtualFile, Artifact> result = new MultiValuesMap<VirtualFile, Artifact>();
  final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
  for (final Artifact artifact : artifactManager.getArtifacts()) {
    final PackagingElementResolvingContext context = artifactManager.getResolvingContext();
    ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
      @Override
      public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
        if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
          final VirtualFile root = ((FileOrDirectoryCopyPackagingElement)element).findFile();
          if (root != null) {
            result.put(root, artifact);
          }
        }
        else if (element instanceof ModuleOutputPackagingElement) {
          for (VirtualFile sourceRoot : ((ModuleOutputPackagingElement)element).getSourceRoots(context)) {
            result.put(sourceRoot, artifact);
          }
        }
        return true;
      }
    }, context, true);
  }
  return result;
}
项目:intellij-ce-playground    文件:ArtifactBySourceFileFinderImpl.java   
@Override
public Collection<? extends Artifact> findArtifacts(@NotNull VirtualFile sourceFile) {
  final MultiValuesMap<VirtualFile, Artifact> map = getFileToArtifactsMap().getValue();
  if (map.isEmpty()) {
    return Collections.emptyList();
  }

  List<Artifact> result = null;
  VirtualFile file = sourceFile;
  while (file != null) {
    final Collection<Artifact> artifacts = map.get(file);
    if (artifacts != null) {
      if (result == null) {
        result = new SmartList<Artifact>();
      }
      result.addAll(artifacts);
    }
    file = file.getParent();
  }
  return result != null ? result : Collections.<Artifact>emptyList();
}
项目:intellij-ce-playground    文件:ArtifactVirtualFileListener.java   
private MultiValuesMap<String, Artifact> computeParentPathToArtifactMap() {
  final MultiValuesMap<String, Artifact> result = new MultiValuesMap<String, Artifact>();
  for (final Artifact artifact : myArtifactManager.getArtifacts()) {
    ArtifactUtil.processFileOrDirectoryCopyElements(artifact, new PackagingElementProcessor<FileOrDirectoryCopyPackagingElement<?>>() {
      @Override
      public boolean process(@NotNull FileOrDirectoryCopyPackagingElement<?> element, @NotNull PackagingElementPath pathToElement) {
        String path = element.getFilePath();
        while (path.length() > 0) {
          result.put(path, artifact);
          path = PathUtil.getParentPath(path);
        }
        return true;
      }
    }, myArtifactManager.getResolvingContext(), false);
  }
  return result;
}
项目:intellij-ce-playground    文件:ProjectViewTestUtil.java   
public static void checkContainsMethod(final Object rootElement,
                                       final AbstractTreeStructure structure,
                                       Function<AbstractTreeNode, VirtualFile[]> converterFunction) {
  MultiValuesMap<VirtualFile, AbstractTreeNode> map = new MultiValuesMap<VirtualFile, AbstractTreeNode>();
  collect((AbstractTreeNode)rootElement, map, structure, converterFunction);

  for (VirtualFile eachFile : map.keySet()) {
    Collection<AbstractTreeNode> nodes = map.values();
    for (final AbstractTreeNode node : nodes) {
      ProjectViewNode eachNode = (ProjectViewNode)node;
      boolean actual = eachNode.contains(eachFile);
      boolean expected = map.get(eachFile).contains(eachNode);
      if (actual != expected) {
        boolean actual1 = eachNode.contains(eachFile);
        boolean expected1 = map.get(eachFile).contains(eachNode);

        Assert.assertTrue("file=" + eachFile + " node=" + eachNode.getTestPresentation() + " expected:" + expected, false);
      }
    }
  }
}
项目:intellij-ce-playground    文件:LogicalRootsManagerImpl.java   
private synchronized  Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> getRoots(final ModuleManager moduleManager) {
  if (myRoots == null) {
    myRoots = new THashMap<Module, MultiValuesMap<LogicalRootType, LogicalRoot>>();

    final Module[] modules = moduleManager.getModules();
    for (Module module : modules) {
      final MultiValuesMap<LogicalRootType, LogicalRoot> map = new MultiValuesMap<LogicalRootType, LogicalRoot>();
      for (Map.Entry<LogicalRootType, Collection<NotNullFunction>> entry : myProviders.entrySet()) {
        final Collection<NotNullFunction> functions = entry.getValue();
        for (NotNullFunction function : functions) {
          map.putAll(entry.getKey(), (List<LogicalRoot>) function.fun(module));
        }
      }
      myRoots.put(module, map);
    }
  }

  return myRoots;
}
项目:intellij-ce-playground    文件:StructureViewFactoryImpl.java   
@NotNull
@Override
public Collection<StructureViewExtension> getAllExtensions(@NotNull Class<? extends PsiElement> type) {
  Collection<StructureViewExtension> result = myImplExtensions.get(type);
  if (result == null) {
    MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> map = myExtensions.getValue();
    for (Class<? extends PsiElement> registeredType : map.keySet()) {
      if (ReflectionUtil.isAssignable(registeredType, type)) {
        final Collection<StructureViewExtension> extensions = map.get(registeredType);
        for (StructureViewExtension extension : extensions) {
          myImplExtensions.put(type, extension);
        }
      }
    }
    result = myImplExtensions.get(type);
    if (result == null) return Collections.emptyList();
  }
  return result;
}
项目:intellij-ce-playground    文件:StaticGenericInfoBuilder.java   
@Nullable
private MultiValuesMap<XmlName, JavaMethod> getAddersMap(final JavaMethod method) {
  final Class<?>[] parameterTypes = method.getParameterTypes();
  switch (parameterTypes.length) {
    case 0:
      return collectionAdders;
    case 1:
      if (Class.class.equals(parameterTypes[0])) return collectionClassAdders;
      if (isInt(parameterTypes[0])) return collectionIndexAdders;
      break;
    case 2:
      if (isIndexClassAdder(parameterTypes[0], parameterTypes[1])) return collectionIndexClassAdders;
      if (isIndexClassAdder(parameterTypes[1], parameterTypes[0])) return collectionClassIndexAdders;
  }
  return null;
}
项目:tools-idea    文件:ArtifactBySourceFileFinderImpl.java   
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
  if (myFile2Artifacts == null) {
    myFile2Artifacts =
      CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
        public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
          MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
          List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
          trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
          for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
            ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
          }
          return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
        }
      }, false);
  }
  return myFile2Artifacts;
}
项目:tools-idea    文件:ArtifactBySourceFileFinderImpl.java   
private MultiValuesMap<VirtualFile, Artifact> computeFileToArtifactsMap() {
  final MultiValuesMap<VirtualFile, Artifact> result = new MultiValuesMap<VirtualFile, Artifact>();
  final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
  for (final Artifact artifact : artifactManager.getArtifacts()) {
    final PackagingElementResolvingContext context = artifactManager.getResolvingContext();
    ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
      @Override
      public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
        if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
          final VirtualFile root = ((FileOrDirectoryCopyPackagingElement)element).findFile();
          if (root != null) {
            result.put(root, artifact);
          }
        }
        else if (element instanceof ModuleOutputPackagingElement) {
          for (VirtualFile sourceRoot : ((ModuleOutputPackagingElement)element).getSourceRoots(context)) {
            result.put(sourceRoot, artifact);
          }
        }
        return true;
      }
    }, context, true);
  }
  return result;
}
项目:tools-idea    文件:ArtifactBySourceFileFinderImpl.java   
@Override
public Collection<? extends Artifact> findArtifacts(@NotNull VirtualFile sourceFile) {
  final MultiValuesMap<VirtualFile, Artifact> map = getFileToArtifactsMap().getValue();
  if (map.isEmpty()) {
    return Collections.emptyList();
  }

  List<Artifact> result = null;
  VirtualFile file = sourceFile;
  while (file != null) {
    final Collection<Artifact> artifacts = map.get(file);
    if (artifacts != null) {
      if (result == null) {
        result = new SmartList<Artifact>();
      }
      result.addAll(artifacts);
    }
    file = file.getParent();
  }
  return result != null ? result : Collections.<Artifact>emptyList();
}
项目:tools-idea    文件:ArtifactVirtualFileListener.java   
private MultiValuesMap<String, Artifact> computeParentPathToArtifactMap() {
  final MultiValuesMap<String, Artifact> result = new MultiValuesMap<String, Artifact>();
  for (final Artifact artifact : myArtifactManager.getArtifacts()) {
    ArtifactUtil.processFileOrDirectoryCopyElements(artifact, new PackagingElementProcessor<FileOrDirectoryCopyPackagingElement<?>>() {
      @Override
      public boolean process(@NotNull FileOrDirectoryCopyPackagingElement<?> element, @NotNull PackagingElementPath pathToElement) {
        String path = element.getFilePath();
        while (path.length() > 0) {
          result.put(path, artifact);
          path = PathUtil.getParentPath(path);
        }
        return true;
      }
    }, myArtifactManager.getResolvingContext(), false);
  }
  return result;
}
项目:tools-idea    文件:ProjectViewTestUtil.java   
public static void checkContainsMethod(final Object rootElement,
                                       final AbstractTreeStructure structure,
                                       Function<AbstractTreeNode, VirtualFile[]> converterFunction) {
  MultiValuesMap<VirtualFile, AbstractTreeNode> map = new MultiValuesMap<VirtualFile, AbstractTreeNode>();
  collect((AbstractTreeNode)rootElement, map, structure, converterFunction);

  for (VirtualFile eachFile : map.keySet()) {
    Collection<AbstractTreeNode> nodes = map.values();
    for (final AbstractTreeNode node : nodes) {
      ProjectViewNode eachNode = (ProjectViewNode)node;
      boolean actual = eachNode.contains(eachFile);
      boolean expected = map.get(eachFile).contains(eachNode);
      if (actual != expected) {
        boolean actual1 = eachNode.contains(eachFile);
        boolean expected1 = map.get(eachFile).contains(eachNode);

        Assert.assertTrue("file=" + eachFile + " node=" + eachNode.getTestPresentation() + " expected:" + expected, false);
      }
    }
  }
}
项目:tools-idea    文件:LogicalRootsManagerImpl.java   
private synchronized  Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> getRoots(final ModuleManager moduleManager) {
  if (myRoots == null) {
    myRoots = new THashMap<Module, MultiValuesMap<LogicalRootType, LogicalRoot>>();

    final Module[] modules = moduleManager.getModules();
    for (Module module : modules) {
      final MultiValuesMap<LogicalRootType, LogicalRoot> map = new MultiValuesMap<LogicalRootType, LogicalRoot>();
      for (Map.Entry<LogicalRootType, Collection<NotNullFunction>> entry : myProviders.entrySet()) {
        final Collection<NotNullFunction> functions = entry.getValue();
        for (NotNullFunction function : functions) {
          map.putAll(entry.getKey(), (List<LogicalRoot>) function.fun(module));
        }
      }
      myRoots.put(module, map);
    }
  }

  return myRoots;
}
项目:tools-idea    文件:StructureViewFactoryImpl.java   
@Override
public Collection<StructureViewExtension> getAllExtensions(Class<? extends PsiElement> type) {
  Collection<StructureViewExtension> result = myImplExtensions.get(type);
  if (result == null) {
    MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> map = myExtensions.getValue();
    for (Class<? extends PsiElement> registeredType : map.keySet()) {
      if (ReflectionCache.isAssignable(registeredType, type)) {
        final Collection<StructureViewExtension> extensions = map.get(registeredType);
        for (StructureViewExtension extension : extensions) {
          myImplExtensions.put(type, extension);
        }
      }
    }
    result = myImplExtensions.get(type);
    if (result == null) return Collections.emptyList();
  }
  return result;
}
项目:tools-idea    文件:StaticGenericInfoBuilder.java   
@Nullable
private MultiValuesMap<XmlName, JavaMethod> getAddersMap(final JavaMethod method) {
  final Class<?>[] parameterTypes = method.getParameterTypes();
  switch (parameterTypes.length) {
    case 0:
      return collectionAdders;
    case 1:
      if (Class.class.equals(parameterTypes[0])) return collectionClassAdders;
      if (isInt(parameterTypes[0])) return collectionIndexAdders;
      break;
    case 2:
      if (isIndexClassAdder(parameterTypes[0], parameterTypes[1])) return collectionIndexClassAdders;
      if (isIndexClassAdder(parameterTypes[1], parameterTypes[0])) return collectionClassIndexAdders;
  }
  return null;
}
项目:consulo    文件:ProjectViewTestUtil.java   
public static void checkContainsMethod(final Object rootElement,
                                       final AbstractTreeStructure structure,
                                       Function<AbstractTreeNode, VirtualFile[]> converterFunction) {
  MultiValuesMap<VirtualFile, AbstractTreeNode> map = new MultiValuesMap<VirtualFile, AbstractTreeNode>();
  collect((AbstractTreeNode)rootElement, map, structure, converterFunction);

  for (VirtualFile eachFile : map.keySet()) {
    Collection<AbstractTreeNode> nodes = map.values();
    for (final AbstractTreeNode node : nodes) {
      ProjectViewNode eachNode = (ProjectViewNode)node;
      boolean actual = eachNode.contains(eachFile);
      boolean expected = map.get(eachFile).contains(eachNode);
      if (actual != expected) {
        boolean actual1 = eachNode.contains(eachFile);
        boolean expected1 = map.get(eachFile).contains(eachNode);

        Assert.assertTrue("file=" + eachFile + " node=" + eachNode.getTestPresentation() + " expected:" + expected, false);
      }
    }
  }
}
项目:consulo    文件:ArtifactBySourceFileFinderImpl.java   
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
  if (myFile2Artifacts == null) {
    myFile2Artifacts =
      CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
        public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
          MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
          List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
          trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
          for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
            ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
          }
          return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
        }
      }, false);
  }
  return myFile2Artifacts;
}
项目:consulo    文件:ArtifactBySourceFileFinderImpl.java   
private MultiValuesMap<VirtualFile, Artifact> computeFileToArtifactsMap() {
  final MultiValuesMap<VirtualFile, Artifact> result = new MultiValuesMap<VirtualFile, Artifact>();
  final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
  for (final Artifact artifact : artifactManager.getArtifacts()) {
    final PackagingElementResolvingContext context = artifactManager.getResolvingContext();
    ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
      @Override
      public boolean process(@Nonnull PackagingElement<?> element, @Nonnull PackagingElementPath path) {
        if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
          final VirtualFile root = ((FileOrDirectoryCopyPackagingElement)element).findFile();
          if (root != null) {
            result.put(root, artifact);
          }
        }
        else if (element instanceof ModuleOutputPackagingElement) {
          for (VirtualFile sourceRoot : ((ModuleOutputPackagingElement)element).getSourceRoots(context)) {
            result.put(sourceRoot, artifact);
          }
        }
        return true;
      }
    }, context, true);
  }
  return result;
}
项目:consulo    文件:ArtifactBySourceFileFinderImpl.java   
@Override
public Collection<? extends Artifact> findArtifacts(@Nonnull VirtualFile sourceFile) {
  final MultiValuesMap<VirtualFile, Artifact> map = getFileToArtifactsMap().getValue();
  if (map.isEmpty()) {
    return Collections.emptyList();
  }

  List<Artifact> result = null;
  VirtualFile file = sourceFile;
  while (file != null) {
    final Collection<Artifact> artifacts = map.get(file);
    if (artifacts != null) {
      if (result == null) {
        result = new SmartList<Artifact>();
      }
      result.addAll(artifacts);
    }
    file = file.getParent();
  }
  return result != null ? result : Collections.<Artifact>emptyList();
}
项目:consulo    文件:ArtifactVirtualFileListener.java   
private MultiValuesMap<String, Artifact> computeParentPathToArtifactMap() {
  final MultiValuesMap<String, Artifact> result = new MultiValuesMap<String, Artifact>();
  for (final Artifact artifact : myArtifactManager.getArtifacts()) {
    ArtifactUtil.processFileOrDirectoryCopyElements(artifact, new PackagingElementProcessor<FileOrDirectoryCopyPackagingElement<?>>() {
      @Override
      public boolean process(@Nonnull FileOrDirectoryCopyPackagingElement<?> element, @Nonnull PackagingElementPath pathToElement) {
        String path = element.getFilePath();
        while (path.length() > 0) {
          result.put(path, artifact);
          path = PathUtil.getParentPath(path);
        }
        return true;
      }
    }, myArtifactManager.getResolvingContext(), false);
  }
  return result;
}
项目:consulo    文件:LogicalRootsManagerImpl.java   
private synchronized  Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> getRoots(final ModuleManager moduleManager) {
  if (myRoots == null) {
    myRoots = new THashMap<Module, MultiValuesMap<LogicalRootType, LogicalRoot>>();

    final Module[] modules = moduleManager.getModules();
    for (Module module : modules) {
      final MultiValuesMap<LogicalRootType, LogicalRoot> map = new MultiValuesMap<LogicalRootType, LogicalRoot>();
      for (Map.Entry<LogicalRootType, Collection<NotNullFunction>> entry : myProviders.entrySet()) {
        final Collection<NotNullFunction> functions = entry.getValue();
        for (NotNullFunction function : functions) {
          map.putAll(entry.getKey(), (List<LogicalRoot>) function.fun(module));
        }
      }
      myRoots.put(module, map);
    }
  }

  return myRoots;
}
项目:consulo    文件:StructureViewFactoryImpl.java   
@Override
public Collection<StructureViewExtension> getAllExtensions(Class<? extends PsiElement> type) {
  Collection<StructureViewExtension> result = myImplExtensions.get(type);
  if (result == null) {
    MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> map = myExtensions.getValue();
    for (Class<? extends PsiElement> registeredType : map.keySet()) {
      if (ReflectionUtil.isAssignable(registeredType, type)) {
        final Collection<StructureViewExtension> extensions = map.get(registeredType);
        for (StructureViewExtension extension : extensions) {
          myImplExtensions.put(type, extension);
        }
      }
    }
    result = myImplExtensions.get(type);
    if (result == null) return Collections.emptyList();
  }
  return result;
}
项目:consulo-xml    文件:StaticGenericInfoBuilder.java   
@Nullable
private MultiValuesMap<XmlName, JavaMethod> getAddersMap(final JavaMethod method) {
  final Class<?>[] parameterTypes = method.getParameterTypes();
  switch (parameterTypes.length) {
    case 0:
      return collectionAdders;
    case 1:
      if (Class.class.equals(parameterTypes[0])) return collectionClassAdders;
      if (isInt(parameterTypes[0])) return collectionIndexAdders;
      break;
    case 2:
      if (isIndexClassAdder(parameterTypes[0], parameterTypes[1])) return collectionIndexClassAdders;
      if (isIndexClassAdder(parameterTypes[1], parameterTypes[0])) return collectionClassIndexAdders;
  }
  return null;
}
项目:intellij-ce-playground    文件:SameNamesJoiner.java   
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
  if (parent instanceof JoinedNode) return children;

  ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();

  MultiValuesMap<Object, AbstractTreeNode> executed = new MultiValuesMap<Object, AbstractTreeNode>();
  for (Iterator<AbstractTreeNode> iterator = children.iterator(); iterator.hasNext();) {
    ProjectViewNode treeNode = (ProjectViewNode)iterator.next();
    Object o = treeNode.getValue();
    if (o instanceof PsiFile) {
      String name = ((PsiFile)o).getVirtualFile().getNameWithoutExtension();
      executed.put(name, treeNode);
    }
    else {
      executed.put(o, treeNode);
    }
  }

  Iterator<Object> keys = executed.keySet().iterator();
  while (keys.hasNext()) {
    Object each = keys.next();
    Collection<AbstractTreeNode> objects = executed.get(each);
    if (objects.size() > 1) {
      result.add(new JoinedNode(objects, new Joined(findPsiFileIn(objects))));
    }
    else if (objects.size() == 1) {
      result.add(objects.iterator().next());
    }
  }

  return result;
}
项目:intellij-ce-playground    文件:ArtifactVirtualFileListener.java   
public ArtifactVirtualFileListener(Project project, final ArtifactManagerImpl artifactManager) {
  myArtifactManager = artifactManager;
  myParentPathsToArtifacts =
    CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<MultiValuesMap<String, Artifact>>() {
      public Result<MultiValuesMap<String, Artifact>> compute() {
        MultiValuesMap<String, Artifact> result = computeParentPathToArtifactMap();
        return Result.createSingleDependency(result, artifactManager.getModificationTracker());
      }
    }, false);
}
项目:intellij-ce-playground    文件:LogicalRootsManagerImpl.java   
@Override
public List<LogicalRoot> getLogicalRoots(@NotNull final Module module) {
  final Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> roots = getRoots(myModuleManager);
  final MultiValuesMap<LogicalRootType, LogicalRoot> valuesMap = roots.get(module);
  if (valuesMap == null) {
    return Collections.emptyList();
  }
  return new ArrayList<LogicalRoot>(valuesMap.values());
}
项目:intellij-ce-playground    文件:LogicalRootsManagerImpl.java   
@Override
public <T extends LogicalRoot> List<T> getLogicalRootsOfType(@NotNull final Module module, @NotNull final LogicalRootType<T> type) {
  final Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> roots = getRoots(myModuleManager);
  final MultiValuesMap<LogicalRootType, LogicalRoot> map = roots.get(module);
  if (map == null) {
    return Collections.emptyList();
  }

  Collection<LogicalRoot> collection = map.get(type);
  if (collection == null) return Collections.emptyList();
  return new ArrayList<T>((Collection<T>)collection);
}
项目:intellij-ce-playground    文件:StructureViewFactoryImpl.java   
@NotNull
@Override
protected MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> compute() {
  MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> map =
    new MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension>();
  StructureViewExtension[] extensions = Extensions.getExtensions(StructureViewExtension.EXTENSION_POINT_NAME);
  for (StructureViewExtension extension : extensions) {
    map.put(extension.getType(), extension);
  }
  return map;
}
项目:tools-idea    文件:DfaUtil.java   
@Nullable("null means DFA analysis has failed (too complex to analyze)")
public static Collection<PsiExpression> getCachedVariableValues(@Nullable final PsiVariable variable, @Nullable final PsiElement context) {
  if (variable == null || context == null) return Collections.emptyList();

  CachedValue<MultiValuesMap<PsiVariable, PsiExpression>> cachedValue = context.getUserData(DFA_VARIABLE_INFO_KEY);
  if (cachedValue == null) {
    final PsiElement codeBlock = DfaPsiUtil.getEnclosingCodeBlock(variable, context);
    cachedValue = CachedValuesManager.getManager(context.getProject()).createCachedValue(new CachedValueProvider<MultiValuesMap<PsiVariable, PsiExpression>>() {
      @Override
      public Result<MultiValuesMap<PsiVariable, PsiExpression>> compute() {
        final MultiValuesMap<PsiVariable, PsiExpression> result;
        if (codeBlock == null) {
          result = null;
        }
        else {
          final ValuableInstructionVisitor visitor = new ValuableInstructionVisitor(context);
          RunnerResult runnerResult = new ValuableDataFlowRunner().analyzeMethod(codeBlock, visitor);
          if (runnerResult == RunnerResult.OK) {
            result = visitor.myValues;
          }
          else {
            result = TOO_COMPLEX;
          }
        }
        return new Result<MultiValuesMap<PsiVariable, PsiExpression>>(result, codeBlock);
      }
    }, false);
    context.putUserData(DFA_VARIABLE_INFO_KEY, cachedValue);
  }
  final MultiValuesMap<PsiVariable, PsiExpression> value = cachedValue.getValue();
  if (value == TOO_COMPLEX) return null;
  final Collection<PsiExpression> expressions = value == null ? null : value.get(variable);
  return expressions == null ? Collections.<PsiExpression>emptyList() : expressions;
}
项目:tools-idea    文件:SameNamesJoiner.java   
@Override
public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {
  if (parent instanceof JoinedNode) return children;

  ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();

  MultiValuesMap<Object, AbstractTreeNode> executed = new MultiValuesMap<Object, AbstractTreeNode>();
  for (Iterator<AbstractTreeNode> iterator = children.iterator(); iterator.hasNext();) {
    ProjectViewNode treeNode = (ProjectViewNode)iterator.next();
    Object o = treeNode.getValue();
    if (o instanceof PsiFile) {
      String name = ((PsiFile)o).getVirtualFile().getNameWithoutExtension();
      executed.put(name, treeNode);
    }
    else {
      executed.put(o, treeNode);
    }
  }

  Iterator<Object> keys = executed.keySet().iterator();
  while (keys.hasNext()) {
    Object each = keys.next();
    Collection<AbstractTreeNode> objects = executed.get(each);
    if (objects.size() > 1) {
      result.add(new JoinedNode(objects, new Joined(findPsiFileIn(objects))));
    }
    else if (objects.size() == 1) {
      result.add(objects.iterator().next());
    }
  }

  return result;
}
项目:tools-idea    文件:ArtifactVirtualFileListener.java   
public ArtifactVirtualFileListener(Project project, final ArtifactManagerImpl artifactManager) {
  myArtifactManager = artifactManager;
  myParentPathsToArtifacts =
    CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<MultiValuesMap<String, Artifact>>() {
      public Result<MultiValuesMap<String, Artifact>> compute() {
        MultiValuesMap<String, Artifact> result = computeParentPathToArtifactMap();
        return Result.createSingleDependency(result, artifactManager.getModificationTracker());
      }
    }, false);
}
项目:tools-idea    文件:LogicalRootsManagerImpl.java   
@Override
public List<LogicalRoot> getLogicalRoots(@NotNull final Module module) {
  final Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> roots = getRoots(myModuleManager);
  final MultiValuesMap<LogicalRootType, LogicalRoot> valuesMap = roots.get(module);
  if (valuesMap == null) {
    return Collections.emptyList();
  }
  return new ArrayList<LogicalRoot>(valuesMap.values());
}
项目:tools-idea    文件:LogicalRootsManagerImpl.java   
@Override
public <T extends LogicalRoot> List<T> getLogicalRootsOfType(@NotNull final Module module, @NotNull final LogicalRootType<T> type) {
  final Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> roots = getRoots(myModuleManager);
  final MultiValuesMap<LogicalRootType, LogicalRoot> map = roots.get(module);
  if (map == null) {
    return Collections.emptyList();
  }

  Collection<LogicalRoot> collection = map.get(type);
  if (collection == null) return Collections.emptyList();
  return new ArrayList<T>((Collection<T>)collection);
}
项目:tools-idea    文件:StructureViewFactoryImpl.java   
@NotNull
@Override
protected MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> compute() {
  MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> map =
    new MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension>();
  StructureViewExtension[] extensions = Extensions.getExtensions(StructureViewExtension.EXTENSION_POINT_NAME);
  for (StructureViewExtension extension : extensions) {
    map.put(extension.getType(), extension);
  }
  return map;
}
项目:consulo    文件:ArtifactVirtualFileListener.java   
public ArtifactVirtualFileListener(Project project, final ArtifactManagerImpl artifactManager) {
  myArtifactManager = artifactManager;
  myParentPathsToArtifacts =
    CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<MultiValuesMap<String, Artifact>>() {
      public Result<MultiValuesMap<String, Artifact>> compute() {
        MultiValuesMap<String, Artifact> result = computeParentPathToArtifactMap();
        return Result.createSingleDependency(result, artifactManager.getModificationTracker());
      }
    }, false);
}
项目:consulo    文件:LogicalRootsManagerImpl.java   
@Override
public List<LogicalRoot> getLogicalRoots(@Nonnull final Module module) {
  final Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> roots = getRoots(myModuleManager);
  final MultiValuesMap<LogicalRootType, LogicalRoot> valuesMap = roots.get(module);
  if (valuesMap == null) {
    return Collections.emptyList();
  }
  return new ArrayList<LogicalRoot>(valuesMap.values());
}
项目:consulo    文件:LogicalRootsManagerImpl.java   
@Override
public <T extends LogicalRoot> List<T> getLogicalRootsOfType(@Nonnull final Module module, @Nonnull final LogicalRootType<T> type) {
  final Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> roots = getRoots(myModuleManager);
  final MultiValuesMap<LogicalRootType, LogicalRoot> map = roots.get(module);
  if (map == null) {
    return Collections.emptyList();
  }

  Collection<LogicalRoot> collection = map.get(type);
  if (collection == null) return Collections.emptyList();
  return new ArrayList<T>((Collection<T>)collection);
}
项目:consulo    文件:StructureViewFactoryImpl.java   
@Nonnull
@Override
protected MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> compute() {
  MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> map =
    new MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension>();
  StructureViewExtension[] extensions = Extensions.getExtensions(StructureViewExtension.EXTENSION_POINT_NAME);
  for (StructureViewExtension extension : extensions) {
    map.put(extension.getType(), extension);
  }
  return map;
}
项目:consulo-java    文件:SameNamesJoiner.java   
@Override
public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {
  if (parent instanceof JoinedNode) return children;

  ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();

  MultiValuesMap<Object, AbstractTreeNode> executed = new MultiValuesMap<Object, AbstractTreeNode>();
  for (Iterator<AbstractTreeNode> iterator = children.iterator(); iterator.hasNext();) {
    ProjectViewNode treeNode = (ProjectViewNode)iterator.next();
    Object o = treeNode.getValue();
    if (o instanceof PsiFile) {
      String name = ((PsiFile)o).getVirtualFile().getNameWithoutExtension();
      executed.put(name, treeNode);
    }
    else {
      executed.put(o, treeNode);
    }
  }

  Iterator<Object> keys = executed.keySet().iterator();
  while (keys.hasNext()) {
    Object each = keys.next();
    Collection<AbstractTreeNode> objects = executed.get(each);
    if (objects.size() > 1) {
      result.add(new JoinedNode(objects, new Joined(findPsiFileIn(objects))));
    }
    else if (objects.size() == 1) {
      result.add(objects.iterator().next());
    }
  }

  return result;
}