com.intellij.util.containers.MultiMap Java Examples

The following examples show how to use com.intellij.util.containers.MultiMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArtifactCompilerUtil.java    From consulo with Apache License 2.0 8 votes vote down vote up
public static MultiMap<String, Artifact> createOutputToArtifactMap(final Project project) {
  final MultiMap<String, Artifact> result = new MultiMap<String, Artifact>() {
    @Nonnull
    @Override
    protected Map<String, Collection<Artifact>> createMap() {
      return new THashMap<String, Collection<Artifact>>(FileUtil.PATH_HASHING_STRATEGY);
    }
  };
  AccessRule.read(() -> {
    for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
      String outputPath = artifact.getOutputFilePath();
      if (!StringUtil.isEmpty(outputPath)) {
        result.putValue(outputPath, artifact);
      }
    }
  });
  return result;
}
 
Example #2
Source File: VcsLogRepoSizeCollector.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Set<UsageDescriptor> getProjectUsages(@Nonnull Project project) throws CollectUsagesException {
  VcsProjectLog projectLog = VcsProjectLog.getInstance(project);
  VcsLogData logData = projectLog.getDataManager();
  if (logData != null) {
    DataPack dataPack = logData.getDataPack();
    if (dataPack.isFull()) {
      PermanentGraph<Integer> permanentGraph = dataPack.getPermanentGraph();
      MultiMap<VcsKey, VirtualFile> groupedRoots = groupRootsByVcs(dataPack.getLogProviders());

      Set<UsageDescriptor> usages = ContainerUtil.newHashSet();
      usages.add(StatisticsUtilKt.getCountingUsage("data.commit.count", permanentGraph.getAllCommits().size(),
                                                   asList(0, 1, 100, 1000, 10 * 1000, 100 * 1000, 500 * 1000)));
      for (VcsKey vcs : groupedRoots.keySet()) {
        usages.add(StatisticsUtilKt.getCountingUsage("data." + vcs.getName().toLowerCase() + ".root.count", groupedRoots.get(vcs).size(),
                                                     asList(0, 1, 2, 5, 8, 15, 30, 50, 100, 500, 1000)));
      }
      return usages;
    }
  }
  return Collections.emptySet();
}
 
Example #3
Source File: VcsAnnotationLocalChangesListenerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public VcsAnnotationLocalChangesListenerImpl(Project project, final ProjectLevelVcsManager vcsManager) {
  myLock = new Object();
  myUpdateStuff = createUpdateStuff();
  myUpdater = new ZipperUpdater(ApplicationManager.getApplication().isUnitTestMode() ? 10 : 300, Alarm.ThreadToUse.POOLED_THREAD, project);
  myConnection = project.getMessageBus().connect();
  myLocalFileSystem = LocalFileSystem.getInstance();
  VcsAnnotationRefresher handler = createHandler();
  myDirtyPaths = new HashSet<>();
  myDirtyChanges = new HashMap<>();
  myDirtyFiles = new HashSet<>();
  myFileAnnotationMap = MultiMap.createSet();
  myVcsManager = vcsManager;
  myVcsKeySet = new HashSet<>();

  myConnection.subscribe(VcsAnnotationRefresher.LOCAL_CHANGES_CHANGED, handler);
}
 
Example #4
Source File: RootIndex.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private LinkedHashSet<OrderEntry> getLibraryOrderEntries(@Nonnull List<VirtualFile> hierarchy,
                                                         @Nullable VirtualFile libraryClassRoot,
                                                         @Nullable VirtualFile librarySourceRoot,
                                                         @Nonnull MultiMap<VirtualFile, OrderEntry> libClassRootEntries,
                                                         @Nonnull MultiMap<VirtualFile, OrderEntry> libSourceRootEntries) {
  LinkedHashSet<OrderEntry> orderEntries = ContainerUtil.newLinkedHashSet();
  for (VirtualFile root : hierarchy) {
    if (root == libraryClassRoot && !sourceRootOf.containsKey(root)) {
      orderEntries.addAll(libClassRootEntries.get(root));
    }
    if (root == librarySourceRoot && libraryClassRoot == null) {
      orderEntries.addAll(libSourceRootEntries.get(root));
    }
    if (libClassRootEntries.containsKey(root) || sourceRootOf.containsKey(root) && librarySourceRoot == null) {
      break;
    }
  }
  return orderEntries;
}
 
Example #5
Source File: RootIndex.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static OrderEntry[] calcOrderEntries(@Nonnull RootInfo info,
                                             @Nonnull MultiMap<VirtualFile, OrderEntry> depEntries,
                                             @Nonnull MultiMap<VirtualFile, OrderEntry> libClassRootEntries,
                                             @Nonnull MultiMap<VirtualFile, OrderEntry> libSourceRootEntries,
                                             @Nonnull List<VirtualFile> hierarchy) {
  @Nullable VirtualFile libraryClassRoot = info.findLibraryRootInfo(hierarchy, false);
  @Nullable VirtualFile librarySourceRoot = info.findLibraryRootInfo(hierarchy, true);
  Set<OrderEntry> orderEntries = ContainerUtil.newLinkedHashSet();
  orderEntries.addAll(info.getLibraryOrderEntries(hierarchy, libraryClassRoot, librarySourceRoot, libClassRootEntries, libSourceRootEntries));
  for (VirtualFile root : hierarchy) {
    orderEntries.addAll(depEntries.get(root));
  }
  VirtualFile moduleContentRoot = info.findModuleRootInfo(hierarchy);
  if (moduleContentRoot != null) {
    ContainerUtil.addIfNotNull(orderEntries, info.getModuleSourceEntry(hierarchy, moduleContentRoot, libClassRootEntries));
  }
  if (orderEntries.isEmpty()) {
    return null;
  }

  OrderEntry[] array = orderEntries.toArray(new OrderEntry[orderEntries.size()]);
  Arrays.sort(array, RootIndex.BY_OWNER_MODULE);
  return array;
}
 
Example #6
Source File: VcsLogUserFilterTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testWeirdCharacters() throws Exception {
  List<String> names = ContainerUtil.newArrayList();

  for (Character c : UserNameRegex.EXTENDED_REGEX_CHARS) {
    String name = "user" + Character.toString(c) + "userovich" + c.hashCode(); // hashCode is required so that uses wont be synonyms
    names.add(name);
    names.add(name + "@company.com");
  }

  MultiMap<VcsUser, String> commits = generateHistory(ArrayUtil.toStringArray(names));
  List<VcsCommitMetadata> metadata = generateMetadata(commits);

  StringBuilder builder = new StringBuilder();
  for (VcsUser user : commits.keySet()) {
    checkFilterForUser(user, commits.keySet(), commits.get(user), metadata, builder);
  }
  assertFilteredCorrectly(builder);
}
 
Example #7
Source File: DotNetLibraryAnalyzerComponent.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
private static MultiMap<String, NamespaceReference> buildCache(File key, String libraryName)
{
	try
	{
		MultiMap<String, NamespaceReference> map = new MultiMap<String, NamespaceReference>();
		TypeDef[] typeDefs = new ModuleParser(key).getTypeDefs();

		for(TypeDef typeDef : typeDefs)
		{
			String namespace = typeDef.getNamespace();
			if(StringUtil.isEmpty(namespace))
			{
				continue;
			}
			map.putValue(MsilHelper.cutGenericMarker(typeDef.getName()), new NamespaceReference(namespace, libraryName));
		}
		return map;
	}
	catch(IOException | MSILParseException ignored)
	{
	}
	return MultiMap.emptyInstance();
}
 
Example #8
Source File: LiveTemplateSettingsEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void addContextNode(MultiMap<TemplateContextType, TemplateContextType> hierarchy,
                            CheckedTreeNode parent,
                            TemplateContextType type) {
  final Collection<TemplateContextType> children = hierarchy.get(type);
  final String name = UIUtil.removeMnemonic(type.getPresentableName());
  final CheckedTreeNode node = new CheckedTreeNode(Pair.create(children.isEmpty() ? type : null, name));
  parent.add(node);

  if (children.isEmpty()) {
    node.setChecked(myContext.get(type));
  }
  else {
    for (TemplateContextType child : children) {
      addContextNode(hierarchy, node, child);
    }
    final CheckedTreeNode other = new CheckedTreeNode(Pair.create(type, "Other"));
    other.setChecked(myContext.get(type));
    node.add(other);
  }
}
 
Example #9
Source File: StatisticsWeigher.java    From consulo with Apache License 2.0 6 votes vote down vote up
private TreeMap<Integer, List<LookupElement>> buildMapByWeight(Iterable<LookupElement> source) {
  MultiMap<String, LookupElement> byName = MultiMap.create();
  List<LookupElement> noStats = new ArrayList<>();
  for (LookupElement element : source) {
    String string = element.getLookupString();
    if (myStringsWithWeights.contains(string)) {
      byName.putValue(string, element);
    } else {
      noStats.add(element);
    }
  }

  TreeMap<Integer, List<LookupElement>> map = new TreeMap<>();
  map.put(0, noStats);
  for (String s : byName.keySet()) {
    List<LookupElement> group = (List<LookupElement>)byName.get(s);
    Collections.sort(group, Comparator.comparing(this::getScalarWeight).reversed());
    map.computeIfAbsent(getMaxWeight(group), __ -> new ArrayList<>()).addAll(group);
  }
  return map;
}
 
Example #10
Source File: VcsDirtyScopeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private VcsInvalidated calculateInvalidated(@Nonnull DirtBuilder dirt) {
  MultiMap<AbstractVcs, FilePath> files = dirt.getFilesForVcs();
  MultiMap<AbstractVcs, FilePath> dirs = dirt.getDirsForVcs();
  if (dirt.isEverythingDirty()) {
    dirs.putAllValues(getEverythingDirtyRoots());
  }
  Set<AbstractVcs> keys = ContainerUtil.union(files.keySet(), dirs.keySet());

  Map<AbstractVcs, VcsDirtyScopeImpl> scopes = ContainerUtil.newHashMap();
  for (AbstractVcs key : keys) {
    VcsDirtyScopeImpl scope = new VcsDirtyScopeImpl(key, myProject);
    scopes.put(key, scope);
    scope.addDirtyData(dirs.get(key), files.get(key));
  }

  return new VcsInvalidated(new ArrayList<>(scopes.values()), dirt.isEverythingDirty());
}
 
Example #11
Source File: BaseRefactoringProcessor.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected boolean showConflicts(@Nonnull MultiMap<PsiElement, String> conflicts, @Nullable final UsageInfo[] usages) {
  if (!conflicts.isEmpty() && ApplicationManager.getApplication().isUnitTestMode()) {
    if (!ConflictsInTestsException.isTestIgnore()) throw new ConflictsInTestsException(conflicts.values());
    return true;
  }

  if (myPrepareSuccessfulSwingThreadCallback != null && !conflicts.isEmpty()) {
    final String refactoringId = getRefactoringId();
    if (refactoringId != null) {
      RefactoringEventData conflictUsages = new RefactoringEventData();
      conflictUsages.putUserData(RefactoringEventData.CONFLICTS_KEY, conflicts.values());
      myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).conflictsDetected(refactoringId, conflictUsages);
    }
    final ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, usages);
    if (!conflictsDialog.showAndGet()) {
      if (conflictsDialog.isShowConflicts()) prepareSuccessful();
      return false;
    }
  }

  prepareSuccessful();
  return true;
}
 
Example #12
Source File: AndroidUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void enableCoeditIfAddToAppDetected(@NotNull Project project) {
  if (isCoeditTransformedProject(project)) {
    return;
  }
  // After a Gradle sync has finished we check the tasks that were run to see if any belong to Flutter.
  Map<ProjectData, MultiMap<String, String>> tasks = getTasksMap(project);
  @NotNull String projectName = project.getName();
  for (ProjectData projectData : tasks.keySet()) {
    MultiMap<String, String> map = tasks.get(projectData);
    Collection<String> col = map.get(FLUTTER_PROJECT_NAME);
    if (col.isEmpty()) {
      col = map.get(""); // Android Studio uses this.
    }
    if (!col.isEmpty()) {
      if (col.parallelStream().anyMatch((x) -> x.startsWith(FLUTTER_TASK_PREFIX))) {
        ApplicationManager.getApplication().invokeLater(() -> enableCoEditing(project));
      }
    }
  }
}
 
Example #13
Source File: VcsAnnotationLocalChangesListenerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void processUnderFile(VirtualFile file) {
  final MultiMap<VirtualFile, FileAnnotation> annotations = new MultiMap<>();
  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();
        }
      }
    }
  }
}
 
Example #14
Source File: FileIncludeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void processIncludingFiles(PsiFile context, Processor<? super Pair<VirtualFile, FileIncludeInfo>> processor) {
  context = context.getOriginalFile();
  VirtualFile contextFile = context.getVirtualFile();
  if (contextFile == null) return;

  String originalName = context.getName();
  Collection<String> names = getPossibleIncludeNames(context, originalName);

  GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
  for (String name : names) {
    MultiMap<VirtualFile, FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludingFileCandidates(name, scope);
    for (VirtualFile candidate : infoList.keySet()) {
      PsiFile psiFile = myPsiManager.findFile(candidate);
      if (psiFile == null || context.equals(psiFile)) continue;
      for (FileIncludeInfo info : infoList.get(candidate)) {
        PsiFileSystemItem item = resolveFileInclude(info, psiFile);
        if (item != null && contextFile.equals(item.getVirtualFile())) {
          if (!processor.process(Pair.create(candidate, info))) {
            return;
          }
        }
      }
    }
  }
}
 
Example #15
Source File: PackageDirectoryCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected MultiMap<String, VirtualFile> compute() {
  MultiMap<String, VirtualFile> result = MultiMap.createLinked();
  for (VirtualFile directory : myPackageDirectories) {
    for (VirtualFile child : directory.getChildren()) {
      String childName = child.getName();
      String packageName = myQname.isEmpty() ? childName : myQname + "." + childName;
      if (child.isDirectory() && isPackageDirectory(child, packageName)) {
        result.putValue(childName, child);
      }
    }
  }
  return result;
}
 
Example #16
Source File: CompletionLookupArrangerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Iterable<LookupElement> sortByRelevance(MultiMap<CompletionSorterImpl, LookupElement> inputBySorter) {
  if (inputBySorter.isEmpty()) return Collections.emptyList();

  final List<Iterable<LookupElement>> byClassifier = new ArrayList<>();
  for (CompletionSorterImpl sorter : myClassifiers.keySet()) {
    ProcessingContext context = createContext();
    byClassifier.add(myClassifiers.get(sorter).classify(inputBySorter.get(sorter), context));
  }
  //noinspection unchecked
  return ContainerUtil.concat(byClassifier.toArray(new Iterable[0]));
}
 
Example #17
Source File: PsiSearchHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processRequests(@Nonnull SearchRequestCollector collector, @Nonnull Processor<? super PsiReference> processor) {
  final Map<SearchRequestCollector, Processor<? super PsiReference>> collectors = ContainerUtil.newHashMap();
  collectors.put(collector, processor);

  ProgressIndicator progress = getOrCreateIndicator();
  appendCollectorsFromQueryRequests(collectors);
  boolean result;
  do {
    MultiMap<Set<IdIndexEntry>, RequestWithProcessor> globals = new MultiMap<>();
    final List<Computable<Boolean>> customs = ContainerUtil.newArrayList();
    final Set<RequestWithProcessor> locals = ContainerUtil.newLinkedHashSet();
    Map<RequestWithProcessor, Processor<PsiElement>> localProcessors = new THashMap<>();
    distributePrimitives(collectors, locals, globals, customs, localProcessors, progress);
    result = processGlobalRequestsOptimized(globals, progress, localProcessors);
    if (result) {
      for (RequestWithProcessor local : locals) {
        result = processSingleRequest(local.request, local.refProcessor);
        if (!result) break;
      }
      if (result) {
        for (Computable<Boolean> custom : customs) {
          result = custom.compute();
          if (!result) break;
        }
      }
      if (!result) break;
    }
  }
  while(appendCollectorsFromQueryRequests(collectors));
  return result;
}
 
Example #18
Source File: PsiSearchHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void collectFiles(@Nonnull MultiMap<Set<IdIndexEntry>, RequestWithProcessor> singles,
                          @Nonnull ProgressIndicator progress,
                          @Nonnull final MultiMap<VirtualFile, RequestWithProcessor> intersectionResult,
                          @Nonnull final MultiMap<VirtualFile, RequestWithProcessor> restResult) {
  for (Map.Entry<Set<IdIndexEntry>, Collection<RequestWithProcessor>> entry : singles.entrySet()) {
    final Set<IdIndexEntry> keys = entry.getKey();
    if (keys.isEmpty()) {
      continue;
    }

    final Collection<RequestWithProcessor> processors = entry.getValue();
    final GlobalSearchScope commonScope = uniteScopes(processors);
    final Set<VirtualFile> intersectionWithContainerNameFiles = intersectionWithContainerNameFiles(commonScope, processors, keys);

    List<VirtualFile> result = new ArrayList<>();
    Processor<VirtualFile> processor = Processors.cancelableCollectProcessor(result);
    processFilesContainingAllKeys(myManager.getProject(), commonScope, null, keys, processor);
    for (final VirtualFile file : result) {
      progress.checkCanceled();
      for (final IdIndexEntry indexEntry : keys) {
        myDumbService.runReadActionInSmartMode(
                () -> FileBasedIndex.getInstance().processValues(IdIndex.NAME, indexEntry, file, (file1, value) -> {
                  int mask = value.intValue();
                  for (RequestWithProcessor single : processors) {
                    final PsiSearchRequest request = single.request;
                    if ((mask & request.searchContext) != 0 && request.searchScope.contains(file1)) {
                      MultiMap<VirtualFile, RequestWithProcessor> result1 =
                              intersectionWithContainerNameFiles == null || !intersectionWithContainerNameFiles.contains(file1) ? restResult : intersectionResult;
                      result1.putValue(file1, single);
                    }
                  }
                  return true;
                }, commonScope));
      }
    }
  }
}
 
Example #19
Source File: MatchPatchPaths.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void putSelected(@Nonnull MultiMap<VirtualFile, AbstractFilePatchInProgress> result,
                                @Nonnull final List<AbstractFilePatchInProgress> variants,
                                @Nonnull AbstractFilePatchInProgress patchInProgress) {
  patchInProgress.setAutoBases(ObjectsConvertor.convert(variants, new Convertor<AbstractFilePatchInProgress, VirtualFile>() {
    @Override
    public VirtualFile convert(AbstractFilePatchInProgress o) {
      return o.getBase();
    }
  }, ObjectsConvertor.NOT_NULL));
  result.putValue(patchInProgress.getBase(), patchInProgress);
}
 
Example #20
Source File: VcsLogOneCommitPerRepoAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
private Map<Repo, VcsFullCommitDetails> convertToSingleElementMap(@Nonnull MultiMap<Repo, VcsFullCommitDetails> groupedCommits) {
  Map<Repo, VcsFullCommitDetails> map = ContainerUtil.newHashMap();
  for (Map.Entry<Repo, Collection<VcsFullCommitDetails>> entry : groupedCommits.entrySet()) {
    Collection<VcsFullCommitDetails> commits = entry.getValue();
    if (commits.size() != 1) {
      return null;
    }
    map.put(entry.getKey(), commits.iterator().next());
  }
  return map;
}
 
Example #21
Source File: FileIncludeIndex.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static MultiMap<VirtualFile, FileIncludeInfoImpl> getIncludingFileCandidates(String fileName, @Nonnull GlobalSearchScope scope) {
  final MultiMap<VirtualFile, FileIncludeInfoImpl> result = new MultiMap<>();
  FileBasedIndex.getInstance().processValues(INDEX_ID, fileName, null, (file, value) -> {
    result.put(file, value);
    return true;
  }, scope);
  return result;
}
 
Example #22
Source File: LinearGraphParser.java    From consulo with Apache License 2.0 5 votes vote down vote up
private TestLinearGraphWithElementsInfo(List<GraphNode> graphNodes,
                                        MultiMap<Integer, GraphEdge> upEdges,
                                        MultiMap<Integer, GraphEdge> downEdges) {
  myGraphNodes = graphNodes;
  myUpEdges = upEdges;
  myDownEdges = downEdges;
}
 
Example #23
Source File: RenameProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static MultiMap<PsiElement, UsageInfo> classifyUsages(Collection<? extends PsiElement> elements, UsageInfo[] usages) {
  final MultiMap<PsiElement, UsageInfo> result = new MultiMap<>();
  for (UsageInfo usage : usages) {
    LOG.assertTrue(usage instanceof MoveRenameUsageInfo);
    if (usage.getReference() instanceof LightElement) {
      continue; //filter out implicit references (e.g. from derived class to super class' default constructor)
    }
    MoveRenameUsageInfo usageInfo = (MoveRenameUsageInfo)usage;
    if (usage instanceof RelatedUsageInfo) {
      final PsiElement relatedElement = ((RelatedUsageInfo)usage).getRelatedElement();
      if (elements.contains(relatedElement)) {
        result.putValue(relatedElement, usage);
      }
    } else {
      PsiElement referenced = usageInfo.getReferencedElement();
      if (elements.contains(referenced)) {
        result.putValue(referenced, usage);
      } else if (referenced != null) {
        PsiElement indirect = referenced.getNavigationElement();
        if (elements.contains(indirect)) {
          result.putValue(indirect, usage);
        }
      }

    }
  }
  return result;
}
 
Example #24
Source File: PullUpConflictsUtil.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public static MultiMap<PsiElement, String> checkConflicts(MemberInfoBase<? extends PsiMember>[] infos,
                                                          PsiClass subclass,
                                                          @Nullable PsiClass superClass,
                                                          @NotNull PsiPackage targetPackage,
                                                          @NotNull PsiDirectory targetDirectory,
                                                          final InterfaceContainmentVerifier interfaceContainmentVerifier) {
  return checkConflicts(infos, subclass, superClass, targetPackage, targetDirectory, interfaceContainmentVerifier, true);
}
 
Example #25
Source File: CanonicalPathMap.java    From consulo with Apache License 2.0 5 votes vote down vote up
CanonicalPathMap(@Nonnull List<String> recursive, @Nonnull List<String> flat) {
  myRecursiveWatchRoots = new ArrayList<>(recursive);
  myFlatWatchRoots = new ArrayList<>(flat);

  List<Pair<String, String>> mapping = ContainerUtil.newSmartList();
  Map<String, String> resolvedPaths = resolvePaths(recursive, flat);
  myCanonicalRecursiveWatchRoots = mapPaths(resolvedPaths, recursive, mapping);
  myCanonicalFlatWatchRoots = mapPaths(resolvedPaths, flat, mapping);

  myPathMapping = MultiMap.createConcurrentSet();
  addMapping(mapping);
}
 
Example #26
Source File: NewMappings.java    From consulo with Apache License 2.0 5 votes vote down vote up
public NewMappings(Project project,
                   ProjectLevelVcsManagerImpl vcsManager,
                   FileStatusManager fileStatusManager) {
  myProject = project;
  myVcsManager = vcsManager;
  myFileStatusManager = fileStatusManager;
  myLock = new Object();
  myVcsToPaths = MultiMap.createOrderedSet();
  myFileWatchRequestsManager = new FileWatchRequestsManager(myProject, this);
  myDefaultVcsRootPolicy = DefaultVcsRootPolicy.getInstance(project);
  myActiveVcses = new AbstractVcs[0];

  if (!myProject.isDefault()) {
    VcsDirectoryMapping mapping = new VcsDirectoryMapping("", "");
    myVcsToPaths.putValue("", mapping);
    mySortedMappings = new VcsDirectoryMapping[]{mapping};
  }
  else {
    mySortedMappings = VcsDirectoryMapping.EMPTY_ARRAY;
  }
  myActivated = false;

  vcsManager.addInitializationRequest(VcsInitObject.MAPPINGS, (DumbAwareRunnable)() -> {
    if (!myProject.isDisposed()) {
      activateActiveVcses();
    }
  });
}
 
Example #27
Source File: HaxePullUpHandler.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkConflicts(final HaxePullUpDialog 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;
}
 
Example #28
Source File: VcsCherryPickManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public MultiMap<VcsCherryPicker, VcsFullCommitDetails> createArrayMultiMap() {
  return new MultiMap<VcsCherryPicker, VcsFullCommitDetails>() {
    @Nonnull
    @Override
    protected Collection<VcsFullCommitDetails> createCollection() {
      return new ArrayList<>();
    }
  };
}
 
Example #29
Source File: XQDocTransformer.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private static String formatTagValuesIfExist(String tag, String tagLabel, MultiMap<String, String> xqDocTags) {
    if (xqDocTags.get(tag).size() > 0) {
        return formatTagValues(tagLabel, xqDocTags.get(tag));
    } else {
        return EMPTY;
    }
}
 
Example #30
Source File: XQDocTransformer.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private static String formatTags(MultiMap<String, String> xqDocTags) {
    StringBuilder sb = new StringBuilder();
    sb.append(formatTagValuesIfExist("@author", "Author", xqDocTags));
    sb.append(formatTagValuesIfExist("@version", "Version", xqDocTags));
    sb.append(formatTagValuesIfExist("@since", "Since", xqDocTags));
    sb.append(formatTagValuesIfExist("@deprecated", "Deprecated", xqDocTags));
    sb.append(formatTagValuesIfExist("@param", PARAMETERS_LABEL, xqDocTags));
    sb.append(formatTagValuesIfExist("@return", "Returns", xqDocTags));
    sb.append(formatTagValuesIfExist("@error", "Throws errors", xqDocTags));
    sb.append(formatTagValuesIfExist("@see", "See", xqDocTags));
    return sb.toString();
}