Java Code Examples for com.intellij.util.containers.ContainerUtil

The following examples show how to use com.intellij.util.containers.ContainerUtil. These examples are extracted from open source projects. 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 Project: idea-gitignore   Source File: GitLanguage.java    License: MIT License 6 votes vote down vote up
/**
 * Returns outer files for the current language.
 *
 * @param project current project
 * @return outer files
 */
@NotNull
@Override
public Set<VirtualFile> getOuterFiles(@NotNull final Project project, boolean dumb) {
    final int key = new HashCodeBuilder().append(project).append(getFileType()).toHashCode();

    if (dumb || (fetched && outerFiles.get(key) != null)) {
        return super.getOuterFiles(project, true);
    }

    fetched = true;
    final Set<VirtualFile> parentFiles = super.getOuterFiles(project, false);
    final ArrayList<VirtualFile> files = new ArrayList<>(ContainerUtil.filter(
            IgnoreFilesIndex.getFiles(project, GitExcludeFileType.INSTANCE),
            virtualFile -> Utils.isInProject(virtualFile, project)
    ));

    ContainerUtil.addAllNotNull(parentFiles, files);
    return outerFiles.getOrElse(key, new HashSet<>());
}
 
Example 2
Source Project: idea-gitignore   Source File: ExternalExec.java    License: MIT License 6 votes vote down vote up
/**
 * Returns list of unignored files for the given directory.
 *
 * @param language to check
 * @param project  current project
 * @param file     current file
 * @return unignored files list
 */
@NotNull
public static List<String> getUnignoredFiles(@NotNull IgnoreLanguage language, @NotNull Project project,
                                             @NotNull VirtualFile file) {
    if (!Utils.isInProject(file, project)) {
        return new ArrayList<>();
    }

    ArrayList<String> result = run(
            language,
            GIT_UNIGNORED_FILES,
            file.getParent(),
            new GitUnignoredFilesOutputParser()
    );
    return ContainerUtil.notNullize(result);
}
 
Example 3
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {
    PsiElement parent = getElement().getParent();
    if(!(parent instanceof XmlAttributeValue)) {
        return Collections.emptyList();
    }

    Collection<PhpClass> phpClasses = new ArrayList<>();

    ContainerUtil.addIfNotNull(phpClasses, XmlHelper.getPhpClassForClassFactory((XmlAttributeValue) parent));
    ContainerUtil.addIfNotNull(phpClasses, XmlHelper.getPhpClassForServiceFactory((XmlAttributeValue) parent));

    Collection<LookupElement> lookupElements = new ArrayList<>();

    for (PhpClass phpClass : phpClasses) {
        lookupElements.addAll(PhpElementsUtil.getClassPublicMethod(phpClass).stream()
            .map(PhpLookupElement::new)
            .collect(Collectors.toList())
        );
    }

    return lookupElements;
}
 
Example 4
Source Project: idea-php-toolbox   Source File: PhpFunctionRegistrarMatcher.java    License: MIT License 6 votes vote down vote up
@Override
public boolean matches(@NotNull LanguageMatcherParameter parameter) {

    PsiElement parent = parameter.getElement().getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return false;
    }

    Collection<JsonSignature> signatures = ContainerUtil.filter(
        parameter.getRegistrar().getSignatures(),
        ContainerConditions.DEFAULT_TYPE_FILTER
    );

    if(signatures.size() == 0) {
        return false;
    }

    return PhpMatcherUtil.matchesArraySignature(parent, signatures);
}
 
Example 5
Source Project: consulo   Source File: SystemInfo.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
protected Map<String, String> compute() {
  if (isUnix && !isMac) {
    try {
      List<String> lines = FileUtil.loadLines("/etc/os-release");
      Map<String, String> info = ContainerUtil.newHashMap();
      for (String line : lines) {
        int p = line.indexOf('=');
        if (p > 0) {
          String name = line.substring(0, p);
          String value = StringUtil.unquoteString(line.substring(p + 1));
          if (!StringUtil.isEmptyOrSpaces(name) && !StringUtil.isEmptyOrSpaces(value)) {
            info.put(name, value);
          }
        }
      }
      return info;
    }
    catch (IOException ignored) {
    }
  }

  return Collections.emptyMap();
}
 
Example 6
Source Project: consulo   Source File: ProjectLibraryTabContext.java    License: Apache License 2.0 6 votes vote down vote up
public ProjectLibraryTabContext(final ClasspathPanel classpathPanel, StructureConfigurableContext context) {
  super(classpathPanel, context);

  StructureLibraryTableModifiableModelProvider projectLibrariesProvider = context.getProjectLibrariesProvider();
  Library[] libraries = projectLibrariesProvider.getModifiableModel().getLibraries();
  final Condition<Library> condition = LibraryEditingUtil.getNotAddedLibrariesCondition(myClasspathPanel.getRootModel());

  myItems = ContainerUtil.filter(libraries, condition);
  ContainerUtil.sort(myItems, new Comparator<Library>() {
    @Override
    public int compare(Library o1, Library o2) {
      return StringUtil.compare(o1.getName(), o2.getName(), false);
    }
  });

  myLibraryList = new JBList(myItems);
  myLibraryList.setCellRenderer(new ColoredListCellRendererWrapper<Library>() {
    @Override
    protected void doCustomize(JList list, Library value, int index, boolean selected, boolean hasFocus) {
      final CellAppearanceEx appearance = OrderEntryAppearanceService.getInstance().forLibrary(classpathPanel.getProject(), value, false);

      appearance.customize(this);
    }
  });
  new ListSpeedSearch(myLibraryList);
}
 
Example 7
Source Project: consulo   Source File: VcsRepositoryManager.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private Map<VirtualFile, Repository> findNewRoots(@Nonnull Set<VirtualFile> knownRoots) {
  Map<VirtualFile, Repository> newRootsMap = ContainerUtil.newHashMap();
  for (VcsRoot root : myVcsManager.getAllVcsRoots()) {
    VirtualFile rootPath = root.getPath();
    if (rootPath != null && !knownRoots.contains(rootPath)) {
      AbstractVcs vcs = root.getVcs();
      VcsRepositoryCreator repositoryCreator = getRepositoryCreator(vcs);
      if (repositoryCreator == null) continue;
      Repository repository = repositoryCreator.createRepositoryIfValid(rootPath);
      if (repository != null) {
        newRootsMap.put(rootPath, repository);
      }
    }
  }
  return newRootsMap;
}
 
Example 8
Source Project: consulo   Source File: NavigationUtil.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public static List<GotoRelatedItem> collectRelatedItems(@Nonnull PsiElement contextElement, @Nullable DataContext dataContext) {
  Set<GotoRelatedItem> items = ContainerUtil.newLinkedHashSet();
  for (GotoRelatedProvider provider : Extensions.getExtensions(GotoRelatedProvider.EP_NAME)) {
    items.addAll(provider.getItems(contextElement));
    if (dataContext != null) {
      items.addAll(provider.getItems(dataContext));
    }
  }
  GotoRelatedItem[] result = items.toArray(new GotoRelatedItem[items.size()]);
  Arrays.sort(result, (i1, i2) -> {
    String o1 = i1.getGroup();
    String o2 = i2.getGroup();
    return StringUtil.isEmpty(o1) ? 1 : StringUtil.isEmpty(o2) ? -1 : o1.compareTo(o2);
  });
  return Arrays.asList(result);
}
 
Example 9
Source Project: consulo   Source File: FragmentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public GreenFragment getGreenFragmentForCollapse(int startNode, int maxWalkSize) {
  if (myRedNodes.value(startNode)) return new GreenFragment(null, null, Collections.<Integer>emptySet());
  Integer upRedNode = getNearRedNode(startNode, maxWalkSize, true);
  Integer downRedNode = getNearRedNode(startNode, maxWalkSize, false);

  Set<Integer> upPart =
    upRedNode != null ? getMiddleNodes(upRedNode, startNode, false) : getWalkNodes(startNode, true, createStopFunction(maxWalkSize));

  Set<Integer> downPart =
    downRedNode != null ? getMiddleNodes(startNode, downRedNode, false) : getWalkNodes(startNode, false, createStopFunction(maxWalkSize));

  Set<Integer> middleNodes = ContainerUtil.union(upPart, downPart);
  if (upRedNode != null) middleNodes.remove(upRedNode);
  if (downRedNode != null) middleNodes.remove(downRedNode);

  return new GreenFragment(upRedNode, downRedNode, middleNodes);
}
 
Example 10
@NotNull
@Override
public Object[] getVariants() {

    ContainerCollectionResolver.ServiceCollector collector = ContainerCollectionResolver
        .ServiceCollector.create(getElement().getProject());

    Collection<ContainerService> values = collector.getServices().values();

    if(!usePrivateServices) {
        values = ContainerUtil.filter(values, service -> !service.isPrivate());
    }

    List<LookupElement> results = new ArrayList<>(ServiceCompletionProvider.getLookupElements(null, values).getLookupElements());
    return results.toArray();
}
 
Example 11
Source Project: consulo   Source File: InspectionManagerEx.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
public static SuppressIntentionAction[] getSuppressActions(@Nonnull InspectionToolWrapper toolWrapper) {
  final InspectionProfileEntry tool = toolWrapper.getTool();
  if (tool instanceof CustomSuppressableInspectionTool) {
    return ((CustomSuppressableInspectionTool)tool).getSuppressActions(null);
  }
  final List<LocalQuickFix> actions = new ArrayList<LocalQuickFix>(Arrays.asList(tool.getBatchSuppressActions(null)));
  if (actions.isEmpty()) {
    final Language language = Language.findLanguageByID(toolWrapper.getLanguage());
    if (language != null) {
      final List<InspectionSuppressor> suppressors = LanguageInspectionSuppressors.INSTANCE.allForLanguage(language);
      for (InspectionSuppressor suppressor : suppressors) {
        final SuppressQuickFix[] suppressActions = suppressor.getSuppressActions(null, tool.getShortName());
        Collections.addAll(actions, suppressActions);
      }
    }
  }
  return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<LocalQuickFix, SuppressIntentionAction>() {
    @Override
    public SuppressIntentionAction fun(final LocalQuickFix fix) {
      return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction((SuppressQuickFix)fix);
    }
  });
}
 
Example 12
Source Project: intellij-haskforce   Source File: HLint.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Parse a single problem from the old hlint output if json is not supported.
 */
@Nullable
public static Problem parseProblemFallback(String lint) {
    List<String> split = StringUtil.split(lint, ":");
    if (split.size() < 5) {
        return null;
    }
    int line = StringUtil.parseInt(split.get(1), 0);
    if (line == 0) {
        return null;
    }
    int column = StringUtil.parseInt(split.get(2), 0);
    if (column == 0) {
        return null;
    }
    String hint = StringUtil.split(split.get(4), "\n").get(0);
    split = StringUtil.split(lint, "\n");
    split = ContainerUtil.subList(split, 2);
    split = StringUtil.split(StringUtil.join(split, "\n"), "Why not:");
    if (split.size() != 2) {
        return null;
    }
    final String from = split.get(0).trim();
    final String to = split.get(1).trim();
    return Problem.forFallback("", "", hint, from, to, "", new String[]{}, "", line, column);
}
 
Example 13
Source Project: consulo   Source File: StructureFilteringStrategy.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private List<FilePath> getFilePathsUnder(@Nonnull ChangesBrowserNode<?> node) {
  List<FilePath> result = Collections.emptyList();
  Object userObject = node.getUserObject();

  if (userObject instanceof FilePath) {
    result = ContainerUtil.list(((FilePath)userObject));
  }
  else if (userObject instanceof Module) {
    result = Arrays.stream(ModuleRootManager.getInstance((Module)userObject).getContentRoots())
            .map(VcsUtil::getFilePath)
            .collect(Collectors.toList());
  }

  return result;
}
 
Example 14
Source Project: consulo   Source File: SymlinkHandlingTest.java    License: Apache License 2.0 6 votes vote down vote up
private void assertVisitedPaths(String... expected) {
  VirtualFile vDir = myFileSystem.findFileByIoFile(myTempDir);
  assertNotNull(vDir);

  Set<String> expectedSet = new HashSet<String>(expected.length + 1, 1);
  ContainerUtil.addAll(expectedSet, FileUtil.toSystemIndependentName(myTempDir.getPath()));
  ContainerUtil.addAll(expectedSet, ContainerUtil.map(expected, new Function<String, String>() {
    @Override
    public String fun(String path) {
      return FileUtil.toSystemIndependentName(path);
    }
  }));

  final Set<String> actualSet = new HashSet<String>();
  VfsUtilCore.visitChildrenRecursively(vDir, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@Nonnull VirtualFile file) {
      actualSet.add(file.getPath());
      return true;
    }
  });

  assertEquals(expectedSet, actualSet);
}
 
Example 15
Source Project: idea-php-symfony2-plugin   Source File: TwigUtil.java    License: MIT License 6 votes vote down vote up
/**
 * Extract template name from embed tag
 *
 * {% embed "teasers_skeleton.html.twig" %}
 */
@Nullable
private static String getTemplateNameForEmbedTag(@NotNull PsiElement embedTag) {
    if(embedTag.getNode().getElementType() == TwigElementTypes.EMBED_TAG) {
        PsiElement fileReference = ContainerUtil.find(YamlHelper.getChildrenFix(embedTag), psiElement ->
            TwigPattern.getTemplateFileReferenceTagPattern().accepts(psiElement)
        );

        if(fileReference != null && TwigUtil.isValidStringWithoutInterpolatedOrConcat(fileReference)) {
            String text = fileReference.getText();
            if(StringUtils.isNotBlank(text)) {
                return text;
            }
        }
    }

    return null;
}
 
Example 16
Source Project: consulo   Source File: RecentLocationsAction.java    License: Apache License 2.0 6 votes vote down vote up
private static void removePlaces(@Nonnull Project project,
                                 @Nonnull ListWithFilter<RecentLocationItem> listWithFilter,
                                 @Nonnull JBList<RecentLocationItem> list,
                                 @Nonnull RecentLocationsDataModel data,
                                 boolean showChanged) {
  List<RecentLocationItem> selectedValue = list.getSelectedValuesList();
  if (selectedValue.isEmpty()) {
    return;
  }

  int index = list.getSelectedIndex();

  IdeDocumentHistory ideDocumentHistory = IdeDocumentHistory.getInstance(project);
  for (RecentLocationItem item : selectedValue) {
    if (showChanged) {
      ContainerUtil.filter(ideDocumentHistory.getChangePlaces(), info -> IdeDocumentHistoryImpl.isSame(info, item.getInfo())).forEach(info -> ideDocumentHistory.removeChangePlace(info));
    }
    else {
      ContainerUtil.filter(ideDocumentHistory.getBackPlaces(), info -> IdeDocumentHistoryImpl.isSame(info, item.getInfo())).forEach(info -> ideDocumentHistory.removeBackPlace(info));
    }
  }

  updateModel(listWithFilter, data, showChanged);

  if (list.getModel().getSize() > 0) ScrollingUtil.selectItem(list, index < list.getModel().getSize() ? index : index - 1);
}
 
Example 17
Source Project: idea-php-toolbox   Source File: PhpFunctionRegistrarMatcher.java    License: MIT License 6 votes vote down vote up
@Override
public boolean matches(@NotNull LanguageMatcherParameter parameter) {

    PsiElement parent = parameter.getElement().getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return false;
    }

    Collection<JsonSignature> signatures = ContainerUtil.filter(
        parameter.getRegistrar().getSignatures(),
        ContainerConditions.DEFAULT_TYPE_FILTER
    );

    if(signatures.size() == 0) {
        return false;
    }

    return PhpMatcherUtil.matchesArraySignature(parent, signatures);
}
 
Example 18
Source Project: consulo   Source File: PatchReader.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public ThrowableComputable<Map<String, Map<String, CharSequence>>, PatchSyntaxException> getAdditionalInfo(@Nullable Set<String> paths) {
  ThrowableComputable<Map<String, Map<String, CharSequence>>, PatchSyntaxException> result;
  PatchSyntaxException e = myAdditionalInfoParser.getSyntaxException();

  if (e != null) {
    result = () -> {
      throw e;
    };
  }
  else {
    Map<String, Map<String, CharSequence>> additionalInfo = ContainerUtil.filter(myAdditionalInfoParser.getResultMap(), path -> paths == null || paths
            .contains(path));
    result = () -> additionalInfo;
  }

  return result;
}
 
Example 19
Source Project: consulo   Source File: CodeStyleSettingPresentation.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns an immutable map containing all standard settings in a mapping of type (group -> settings contained in the group).
 * Notice that lists containing settings for a specific group are also immutable. Use copies to make modifications.
 *
 * @param settingsType type to get standard settings for
 * @return mapping setting groups to contained setting presentations
 */
@Nonnull
public static Map<SettingsGroup, List<CodeStyleSettingPresentation>> getStandardSettings(LanguageCodeStyleSettingsProvider.SettingsType settingsType) {
  switch (settingsType) {
    case BLANK_LINES_SETTINGS:
      return BLANK_LINES_STANDARD_SETTINGS;
    case SPACING_SETTINGS:
      return SPACING_STANDARD_SETTINGS;
    case WRAPPING_AND_BRACES_SETTINGS:
      return WRAPPING_AND_BRACES_STANDARD_SETTINGS;
    case INDENT_SETTINGS:
      return INDENT_STANDARD_SETTINGS;
    case LANGUAGE_SPECIFIC:
  }
  return ContainerUtil.newLinkedHashMap();
}
 
Example 20
Source Project: idea-php-shopware-plugin   Source File: ServiceCollectorTest.java    License: MIT License 6 votes vote down vote up
public void testCollectionForSubscriberEvents() {
    ServiceCollector serviceCollector = new ServiceCollector();

    Collection<String> names = new ArrayList<>();
    serviceCollector.collectIds(new ServiceCollectorParameter.Id(getProject(), names));
    assertTrue(names.contains("foobar.my.subscriber"));

    Collection<ServiceInterface> services = new ArrayList<>();
    serviceCollector.collectServices(new ServiceCollectorParameter.Service(getProject(), services));

    ServiceInterface service = ContainerUtil.find(services, serviceInterface ->
        serviceInterface.getId().equals("foobar.my.subscriber")
    );

    assertNotNull(service);
    assertEquals("Foo\\MySubscriber", service.getClassName());
}
 
Example 21
Source Project: consulo   Source File: DvcsTaskHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private List<R> getRepositories(@Nonnull Collection<String> urls) {
  final List<R> repositories = myRepositoryManager.getRepositories();
  return ContainerUtil.mapNotNull(urls, new NullableFunction<String, R>() {
    @Nullable
    @Override
    public R fun(final String s) {

      return ContainerUtil.find(repositories, new Condition<R>() {
        @Override
        public boolean value(R repository) {
          return s.equals(repository.getPresentableUrl());
        }
      });
    }
  });
}
 
Example 22
Source Project: consulo   Source File: DefaultInspectionToolPresentation.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public FileStatus getProblemStatus(@Nonnull final CommonProblemDescriptor descriptor) {
  final GlobalInspectionContextImpl context = getContext();
  if (!isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){
    if (myOldProblemElements != null){
      final Set<CommonProblemDescriptor> allAvailable = new HashSet<CommonProblemDescriptor>();
      for (CommonProblemDescriptor[] descriptors : myOldProblemElements.values()) {
        if (descriptors != null) {
          ContainerUtil.addAll(allAvailable, descriptors);
        }
      }
      final boolean old = containsDescriptor(descriptor, allAvailable);
      final boolean current = containsDescriptor(descriptor, getProblemToElements().keySet());
      return calcStatus(old, current);
    }
  }
  return FileStatus.NOT_CHANGED;
}
 
Example 23
Source Project: consulo   Source File: RollbackAction.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean hasReversibleFiles(@Nonnull AnActionEvent e) {
  ChangeListManager manager = ChangeListManager.getInstance(e.getRequiredData(CommonDataKeys.PROJECT));
  Set<VirtualFile> modifiedWithoutEditing = ContainerUtil.newHashSet(manager.getModifiedWithoutEditing());

  return notNullize(e.getData(VcsDataKeys.VIRTUAL_FILE_STREAM)).anyMatch(
          file -> manager.haveChangesUnder(file) != ThreeState.NO || manager.isFileAffected(file) || modifiedWithoutEditing.contains(file));
}
 
Example 24
Source Project: consulo   Source File: EditorGutterComponentImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public Point getCenterPoint(final GutterIconRenderer renderer) {
  final Ref<Point> result = Ref.create();
  if (!areIconsShown()) {
    processGutterRenderers((line, renderers) -> {
      if (ContainerUtil.find(renderers, renderer) != null) {
        result.set(new Point(getIconAreaOffset(), getLineCenterY(line)));
        return false;
      }
      return true;
    });
  }
  else {
    processGutterRenderers((line, renderers) -> {
      processIconsRow(line, renderers, (x, y, r) -> {
        if (result.isNull() && r.equals(renderer)) {
          Icon icon = scaleIcon(r.getIcon());
          result.set(new Point(x + icon.getIconWidth() / 2, y + icon.getIconHeight() / 2));
        }
      });

      return result.isNull();
    });
  }
  return result.get();
}
 
Example 25
public void testRemoveUnusedImportQuickFix() {
    final String testName = getTestName();

    Collection<Class<? extends LocalInspectionTool>> inspections = new ArrayList<Class<? extends LocalInspectionTool>>();
    inspections.add(UnusedImportsInspection.class);
    myFixture.enableInspections(inspections);
    myFixture.configureByFile(String.format("%s.xq", testName));

    List<IntentionAction> availableIntentions = myFixture.filterAvailableIntentions(UnusedImportsInspection.REMOVE_UNUSED_IMPORT_QUICKFIX_NAME);
    IntentionAction action = ContainerUtil.getFirstItem(availableIntentions);
    assertNotNull(action);
    myFixture.launchAction(action);

    myFixture.checkResultByFile(String.format("%s_after.xq", testName));
}
 
Example 26
Source Project: consulo   Source File: PushController.java    License: Apache License 2.0 5 votes vote down vote up
private boolean hasCheckedNodesWithContent(@Nonnull Collection<RepositoryNode> nodes, final boolean withRefs) {
  return ContainerUtil.exists(nodes, new Condition<RepositoryNode>() {
    @Override
    public boolean value(@Nonnull RepositoryNode node) {
      return node.isChecked() && (withRefs || !myView2Model.get(node).getLoadedCommits().isEmpty());
    }
  });
}
 
Example 27
Source Project: consulo   Source File: TreeChangeImpl.java    License: Apache License 2.0 5 votes vote down vote up
void fireEvents(PsiFile file) {
  int start = myParent.getStartOffset();
  Collection<ChangeInfoImpl> changes = getAllChanges().values();
  if (ContainerUtil.exists(changes, c -> c.hasNoPsi())) {
    ChangeInfoImpl.childrenChanged(ChangeInfoImpl.createEvent(file, start), myParent, myParent.getTextLength() - getLengthDelta());
    return;
  }

  for (ChangeInfoImpl change : changes) {
    change.fireEvent(start, file, myParent);
  }
}
 
Example 28
Source Project: consulo   Source File: VcsCherryPickAction.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
private static List<VcsCherryPicker> getActiveCherryPickersForProject(@Nullable final Project project) {
  if (project != null) {
    final ProjectLevelVcsManager projectLevelVcsManager = ProjectLevelVcsManager.getInstance(project);
    AbstractVcs[] vcss = projectLevelVcsManager.getAllActiveVcss();
    return ContainerUtil.mapNotNull(vcss, vcs -> vcs != null ? VcsCherryPickManager.getInstance(project)
            .getCherryPickerFor(vcs.getKeyInstanceMethod()) : null);
  }
  return ContainerUtil.emptyList();
}
 
Example 29
@NotNull
@Override
public Collection<FluidNamespace> provideForElement(@NotNull PsiElement element) {
    PsiFile[] filesByName = FilenameIndex.getFilesByName(element.getProject(), "ext_localconf.php", GlobalSearchScope.allScope(element.getProject()));

    return ContainerUtil.emptyList();
}
 
Example 30
Source Project: idea-gitignore   Source File: IgnoreManager.java    License: MIT License 5 votes vote down vote up
/**
 * Finds {@link VirtualFile} directory of {@link VcsRoot} that contains passed file.
 *
 * @param file to check
 * @return VCS Root for given file
 */
@Nullable
private VirtualFile getVcsRootFor(@NotNull final VirtualFile file) {
    final VcsRoot vcsRoot = ContainerUtil.find(
            ContainerUtil.reverse(vcsRoots),
            root -> Utils.isUnder(file, root.getPath())
    );
    return vcsRoot != null ? vcsRoot.getPath() : null;
}