com.intellij.util.indexing.FindSymbolParameters Java Examples

The following examples show how to use com.intellij.util.indexing.FindSymbolParameters. 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: AbstractTreeClassChooserDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Object[] getElementsByName(String name, FindSymbolParameters parameters, @Nonnull ProgressIndicator canceled) {
  String patternName = parameters.getLocalPatternName();
  List<T> classes = myTreeClassChooserDialog.getClassesByName(name, parameters.isSearchInLibraries(), patternName, myTreeClassChooserDialog.getScope());
  if (classes.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY;
  if (classes.size() == 1) {
    return isAccepted(classes.get(0)) ? ArrayUtil.toObjectArray(classes) : ArrayUtil.EMPTY_OBJECT_ARRAY;
  }
  Set<String> qNames = ContainerUtil.newHashSet();
  List<T> list = new ArrayList<T>(classes.size());
  for (T aClass : classes) {
    if (qNames.add(getFullName(aClass)) && isAccepted(aClass)) {
      list.add(aClass);
    }
  }
  return ArrayUtil.toObjectArray(list);
}
 
Example #2
Source File: DefaultFileNavigationContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> _processor, @Nonnull FindSymbolParameters parameters) {
  final boolean globalSearch = parameters.getSearchScope().isSearchInLibraries();
  final Processor<PsiFileSystemItem> processor = item -> {
    if (!globalSearch && ProjectCoreUtil.isProjectOrWorkspaceFile(item.getVirtualFile())) {
      return true;
    }
    return _processor.process(item);
  };

  boolean directoriesOnly = isDirectoryOnlyPattern(parameters);
  if (!directoriesOnly) {
    FilenameIndex.processFilesByName(name, false, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }

  if (directoriesOnly || Registry.is("ide.goto.file.include.directories")) {
    FilenameIndex.processFilesByName(name, true, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }
}
 
Example #3
Source File: DefaultChooseByNameItemProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean filterElements(@Nonnull ChooseByNameViewModel base,
                                      @Nonnull ProgressIndicator indicator,
                                      @Nullable PsiElement context,
                                      @Nullable Supplier<String[]> allNamesProducer,
                                      @Nonnull Processor<FoundItemDescriptor<?>> consumer,
                                      @Nonnull FindSymbolParameters parameters) {
  boolean everywhere = parameters.isSearchInLibraries();
  String pattern = parameters.getCompletePattern();
  if (base.getProject() != null) {
    base.getProject().putUserData(ChooseByNamePopup.CURRENT_SEARCH_PATTERN, pattern);
  }

  String namePattern = getNamePattern(base, pattern);
  boolean preferStartMatches = !pattern.startsWith("*");

  List<MatchResult> namesList = getSortedNamesForAllWildcards(base, parameters, indicator, allNamesProducer, namePattern, preferStartMatches);

  indicator.checkCanceled();

  return processByNames(base, everywhere, indicator, context, consumer, preferStartMatches, namesList, parameters);
}
 
Example #4
Source File: CSharpSymbolNameContributor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
public void processElementsWithName(
		@Nonnull String name, @Nonnull Processor<NavigationItem> navigationItemProcessor, @Nonnull FindSymbolParameters findSymbolParameters)
{
	Project project = findSymbolParameters.getProject();
	IdFilter idFilter = findSymbolParameters.getIdFilter();
	GlobalSearchScope searchScope = findSymbolParameters.getSearchScope();

	StubIndex.getInstance().processElements(CSharpIndexKeys.METHOD_INDEX, name, project, searchScope, idFilter,
			DotNetLikeMethodDeclaration.class, (Processor) navigationItemProcessor);
	StubIndex.getInstance().processElements(CSharpIndexKeys.EVENT_INDEX, name, project, searchScope, idFilter,
			DotNetEventDeclaration.class,  (Processor) navigationItemProcessor);
	StubIndex.getInstance().processElements(CSharpIndexKeys.PROPERTY_INDEX, name, project, searchScope, idFilter,
			DotNetPropertyDeclaration.class, (Processor) navigationItemProcessor);
	StubIndex.getInstance().processElements(CSharpIndexKeys.FIELD_INDEX, name, project, searchScope, idFilter,
			DotNetFieldDeclaration.class, (Processor) navigationItemProcessor);
}
 
Example #5
Source File: ContributorsBasedGotoByModel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void processContributorNames(@Nonnull ChooseByNameContributor contributor, @Nonnull FindSymbolParameters parameters, @Nonnull Processor<? super String> nameProcessor) {
  TIntHashSet filter = new TIntHashSet(1000);
  if (contributor instanceof ChooseByNameContributorEx) {
    ((ChooseByNameContributorEx)contributor).processNames(s -> {
      if (nameProcessor.process(s)) {
        filter.add(s.hashCode());
      }
      return true;
    }, parameters.getSearchScope(), parameters.getIdFilter());
  }
  else {
    String[] names = contributor.getNames(myProject, parameters.isSearchInLibraries());
    for (String element : names) {
      if (nameProcessor.process(element)) {
        filter.add(element.hashCode());
      }
    }
  }
  myContributorToItsSymbolsMap.put(contributor, filter);
}
 
Example #6
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
private boolean processItemsForPattern(@Nonnull ChooseByNameBase base,
                                       @Nonnull FindSymbolParameters parameters,
                                       @Nonnull Processor<FoundItemDescriptor<?>> consumer,
                                       @Nonnull ProgressIndicator indicator) {
  String sanitized = getSanitizedPattern(parameters.getCompletePattern(), myModel);
  int qualifierEnd = sanitized.lastIndexOf('/') + 1;
  NameGrouper grouper = new NameGrouper(sanitized.substring(qualifierEnd), indicator);
  processNames(FindSymbolParameters.simple(myProject, true), grouper::processName);

  Ref<Boolean> hasSuggestions = Ref.create(false);
  DirectoryPathMatcher dirMatcher = DirectoryPathMatcher.root(myModel, sanitized.substring(0, qualifierEnd));
  while (dirMatcher != null) {
    int index = grouper.index;
    SuffixMatches group = grouper.nextGroup(base);
    if (group == null) break;
    if (!group.processFiles(parameters.withLocalPattern(dirMatcher.dirPattern), consumer, hasSuggestions, dirMatcher)) {
      return false;
    }
    dirMatcher = dirMatcher.appendChar(grouper.namePattern.charAt(index));
    if (!myModel.isSlashlessMatchingEnabled()) {
      return true;
    }
  }
  return true;
}
 
Example #7
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Iterable<FoundItemDescriptor<PsiFileSystemItem>> getItemsForNames(@Nonnull ProgressIndicator indicator, FindSymbolParameters parameters, List<MatchResult> matchResults) {
  List<PsiFileSystemItem> group = new ArrayList<>();
  Map<PsiFileSystemItem, Integer> nesting = new HashMap<>();
  Map<PsiFileSystemItem, Integer> matchDegrees = new HashMap<>();
  for (MatchResult matchResult : matchResults) {
    ProgressManager.checkCanceled();
    for (Object o : myModel.getElementsByName(matchResult.elementName, parameters, indicator)) {
      ProgressManager.checkCanceled();
      if (o instanceof PsiFileSystemItem) {
        PsiFileSystemItem psiItem = (PsiFileSystemItem)o;
        String qualifier = getParentPath(psiItem);
        if (qualifier != null) {
          group.add(psiItem);
          nesting.put(psiItem, StringUtil.countChars(qualifier, '/'));
          matchDegrees.put(psiItem, matchResult.matchingDegree);
        }
      }
    }
  }

  if (group.size() > 1) {
    Collections.sort(group, Comparator.<PsiFileSystemItem, Integer>comparing(nesting::get).
            thenComparing(getPathProximityComparator()).
            thenComparing(myModel::getFullName));
  }
  return ContainerUtil.map(group, item -> new FoundItemDescriptor<>(item, matchDegrees.get(item)));
}
 
Example #8
Source File: DefaultChooseByNameItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static MinusculeMatcher getFullMatcher(FindSymbolParameters parameters, ChooseByNameViewModel base) {
  String fullRawPattern = buildFullPattern(base, parameters.getCompletePattern());
  String fullNamePattern = buildFullPattern(base, base.transformPattern(parameters.getCompletePattern()));

  return NameUtil.buildMatcherWithFallback(fullRawPattern, fullNamePattern, NameUtil.MatchingCaseSensitivity.NONE);
}
 
Example #9
Source File: DefaultChooseByNameItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static FindSymbolParameters createParameters(@Nonnull ChooseByNameViewModel base, @Nonnull String pattern, boolean everywhere) {
  ChooseByNameModel model = base.getModel();
  IdFilter idFilter = model instanceof ContributorsBasedGotoByModel ? ((ContributorsBasedGotoByModel)model).getIdFilter(everywhere) : null;
  GlobalSearchScope searchScope = FindSymbolParameters.searchScopeFor(base.getProject(), everywhere);
  return new FindSymbolParameters(pattern, getNamePattern(base, pattern), searchScope, idFilter);
}
 
Example #10
Source File: DefaultChooseByNameItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean filterElementsWithWeights(@Nonnull ChooseByNameBase base,
                                         @Nonnull FindSymbolParameters parameters,
                                         @Nonnull ProgressIndicator indicator,
                                         @Nonnull Processor<FoundItemDescriptor<?>> consumer) {
  return ProgressManager.getInstance()
          .computePrioritized(() -> filterElements(base, indicator, myContext == null ? null : myContext.getElement(), () -> base.getNames(parameters.isSearchInLibraries()), consumer, parameters));
}
 
Example #11
Source File: ContributorsBasedGotoByModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public String[] getNames(final boolean checkBoxState) {
  final THashSet<String> allNames = new THashSet<>();

  Collection<String> result = Collections.synchronizedCollection(allNames);
  processNames(Processors.cancelableCollectProcessor(result), FindSymbolParameters.simple(myProject, checkBoxState));
  if (LOG.isDebugEnabled()) {
    LOG.debug("getNames(): (got " + allNames.size() + " elements)");
  }
  return ArrayUtilRt.toStringArray(allNames);
}
 
Example #12
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
boolean processFiles(@Nonnull FindSymbolParameters parameters,
                     @Nonnull Processor<FoundItemDescriptor<?>> processor,
                     @Nonnull Ref<Boolean> hasSuggestions,
                     @Nonnull DirectoryPathMatcher dirMatcher) {
  MinusculeMatcher qualifierMatcher = getQualifiedNameMatcher(parameters.getLocalPatternName());

  List<MatchResult> matchingNames = this.matchingNames;
  if (patternSuffix.length() <= 3 && !dirMatcher.dirPattern.isEmpty()) {
    // just enumerate over files
    // otherwise there are too many names matching the remaining few letters, and querying index for all of them with a very constrained scope is expensive
    Set<String> existingNames = dirMatcher.findFileNamesMatchingIfCheap(patternSuffix.charAt(0), matcher);
    if (existingNames != null) {
      matchingNames = ContainerUtil.filter(matchingNames, mr -> existingNames.contains(mr.elementName));
    }
  }

  List<List<MatchResult>> groups = groupByMatchingDegree(!parameters.getCompletePattern().startsWith("*"), matchingNames);
  for (List<MatchResult> group : groups) {
    JBIterable<FoundItemDescriptor<PsiFileSystemItem>> filesMatchingPath = getFilesMatchingPath(parameters, group, dirMatcher, indicator);
    Iterable<FoundItemDescriptor<PsiFileSystemItem>> matchedFiles =
            parameters.getLocalPatternName().isEmpty() ? filesMatchingPath : matchQualifiers(qualifierMatcher, filesMatchingPath.map(res -> res.getItem()));

    matchedFiles = moveDirectoriesToEnd(matchedFiles);
    Processor<FoundItemDescriptor<PsiFileSystemItem>> trackingProcessor = res -> {
      hasSuggestions.set(true);
      return processor.process(res);
    };
    if (!ContainerUtil.process(matchedFiles, trackingProcessor)) {
      return false;
    }
  }

  // let the framework switch to searching outside project to display these well-matching suggestions
  // instead of worse-matching ones in project (that are very expensive to calculate)
  return hasSuggestions.get() || parameters.isSearchInLibraries() || !hasSuggestionsOutsideProject(parameters.getCompletePattern(), groups, dirMatcher);
}
 
Example #13
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private JBIterable<FoundItemDescriptor<PsiFileSystemItem>> getFilesMatchingPath(@Nonnull FindSymbolParameters parameters,
                                                                                @Nonnull List<MatchResult> fileNames,
                                                                                @Nonnull DirectoryPathMatcher dirMatcher,
                                                                                @Nonnull ProgressIndicator indicator) {
  GlobalSearchScope scope = dirMatcher.narrowDown(parameters.getSearchScope());
  FindSymbolParameters adjusted = parameters.withScope(scope);

  List<List<MatchResult>> sortedNames = sortAndGroup(fileNames, Comparator.comparing(mr -> StringUtil.toLowerCase(FileUtilRt.getNameWithoutExtension(mr.elementName))));
  return JBIterable.from(sortedNames).flatMap(nameGroup -> getItemsForNames(indicator, adjusted, nameGroup));
}
 
Example #14
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Invoke contributors directly, as multi-threading isn't of much value in Goto File,
 * and filling {@link ContributorsBasedGotoByModel#myContributorToItsSymbolsMap} is expensive for the default contributor.
 */
private void processNames(@Nonnull FindSymbolParameters parameters, @Nonnull Processor<? super String> nameProcessor) {
  List<ChooseByNameContributor> contributors = DumbService.getDumbAwareExtensions(myProject, ChooseByNameContributor.FILE_EP_NAME);
  for (ChooseByNameContributor contributor : contributors) {
    if (contributor instanceof DefaultFileNavigationContributor) {
      FilenameIndex.processAllFileNames(nameProcessor, parameters.getSearchScope(), // todo why it was true?
                                        parameters.getIdFilter());
    }
    else {
      myModel.processContributorNames(contributor, parameters, nameProcessor);
    }
  }
}
 
Example #15
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean filterElementsWithWeights(@Nonnull ChooseByNameBase base,
                                         @Nonnull FindSymbolParameters parameters,
                                         @Nonnull ProgressIndicator indicator,
                                         @Nonnull Processor<FoundItemDescriptor<?>> consumer) {
  return ProgressManager.getInstance().computePrioritized(() -> doFilterElements(base, parameters, indicator, consumer));
}
 
Example #16
Source File: ORModuleContributor.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Override
public void processElementsWithName(@NotNull String name, @NotNull Processor<? super NavigationItem> processor, @NotNull FindSymbolParameters parameters) {
    Project project = parameters.getProject();
    GlobalSearchScope scope = parameters.getSearchScope();

    for (PsiModule psiModule : PsiFinder.getInstance(project).findModulesbyName(name, ORFileType.both, null, scope)) {
        processor.process(psiModule);
    }
}
 
Example #17
Source File: UnityScriptGotoClassContributor.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems)
{
	CommonProcessors.CollectProcessor<NavigationItem> processor = new CommonProcessors.CollectProcessor<NavigationItem>(ContainerUtil.<NavigationItem>newTroveSet());
	processElementsWithName(name, processor, new FindSymbolParameters(pattern, name, GlobalSearchScope.allScope(project), IdFilter.getProjectIdFilter(project, includeNonProjectItems)));
	return processor.toArray(NavigationItem.ARRAY_FACTORY);
}
 
Example #18
Source File: CSharpTypeNameContributor.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems)
{
	CommonProcessors.CollectProcessor<NavigationItem> processor = new CommonProcessors.CollectProcessor<NavigationItem>(ContainerUtil.<NavigationItem>newTroveSet());
	processElementsWithName(name, processor, new FindSymbolParameters(pattern, name, GlobalSearchScope.allScope(project), IdFilter.getProjectIdFilter(project, includeNonProjectItems)));
	return processor.toArray(NavigationItem.ARRAY_FACTORY);
}
 
Example #19
Source File: CSharpTypeNameContributor.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> navigationItemProcessor, @Nonnull FindSymbolParameters findSymbolParameters)
{
	Project project = findSymbolParameters.getProject();
	IdFilter idFilter = findSymbolParameters.getIdFilter();
	Processor temp = navigationItemProcessor;
	GlobalSearchScope searchScope = findSymbolParameters.getSearchScope();

	StubIndex.getInstance().processElements(CSharpIndexKeys.TYPE_INDEX, name, project, searchScope, idFilter, CSharpTypeDeclaration.class, temp);
	StubIndex.getInstance().processElements(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, name, project, searchScope, idFilter, CSharpMethodDeclaration.class, temp);
}
 
Example #20
Source File: ChooseByNameContributorEx.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link #processNames(Processor, GlobalSearchScope, IdFilter)} instead
 */
@Deprecated
@Override
@Nonnull
default String[] getNames(Project project, boolean includeNonProjectItems) {
  List<String> result = new ArrayList<>();
  processNames(result::add, FindSymbolParameters.searchScopeFor(project, includeNonProjectItems), null);
  return ArrayUtilRt.toStringArray(result);
}
 
Example #21
Source File: ChooseByNameContributorEx.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link #processElementsWithName(String, Processor, FindSymbolParameters)} instead
 */
@Deprecated
@Override
@Nonnull
default NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
  List<NavigationItem> result = new ArrayList<>();
  processElementsWithName(name, result::add, FindSymbolParameters.simple(project, includeNonProjectItems));
  return result.isEmpty() ? NavigationItem.EMPTY_NAVIGATION_ITEM_ARRAY : result.toArray(NavigationItem.EMPTY_NAVIGATION_ITEM_ARRAY);
}
 
Example #22
Source File: AbstractGotoSEContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void fetchWeightedElements(@Nonnull String pattern, @Nonnull ProgressIndicator progressIndicator, @Nonnull Processor<? super FoundItemDescriptor<Object>> consumer) {
  if (myProject == null) return; //nowhere to search
  if (!isEmptyPatternSupported() && pattern.isEmpty()) return;

  ProgressIndicatorUtils.yieldToPendingWriteActions();
  ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(() -> {
    if (!isDumbAware() && DumbService.isDumb(myProject)) return;

    FilteringGotoByModel<?> model = createModel(myProject);
    if (progressIndicator.isCanceled()) return;

    PsiElement context = psiContext != null && psiContext.isValid() ? psiContext : null;
    ChooseByNamePopup popup = ChooseByNamePopup.createPopup(myProject, model, context);
    try {
      ChooseByNameItemProvider provider = popup.getProvider();
      GlobalSearchScope scope = Registry.is("search.everywhere.show.scopes") ? (GlobalSearchScope)ObjectUtils.notNull(myScopeDescriptor.getScope()) : null;

      boolean everywhere = scope == null ? myEverywhere : scope.isSearchInLibraries();
      if (scope != null && provider instanceof ChooseByNameInScopeItemProvider) {
        FindSymbolParameters parameters = FindSymbolParameters.wrap(pattern, scope);
        ((ChooseByNameInScopeItemProvider)provider)
                .filterElementsWithWeights(popup, parameters, progressIndicator, item -> processElement(progressIndicator, consumer, model, item.getItem(), item.getWeight()));
      }
      else if (provider instanceof ChooseByNameWeightedItemProvider) {
        ((ChooseByNameWeightedItemProvider)provider)
                .filterElementsWithWeights(popup, pattern, everywhere, progressIndicator, item -> processElement(progressIndicator, consumer, model, item.getItem(), item.getWeight()));
      }
      else {
        provider.filterElements(popup, pattern, everywhere, progressIndicator, element -> processElement(progressIndicator, consumer, model, element, getElementPriority(element, pattern)));
      }
    }
    finally {
      Disposer.dispose(popup);
    }
  }, progressIndicator);
}
 
Example #23
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean doFilterElements(@Nonnull ChooseByNameBase base,
                                 @Nonnull FindSymbolParameters parameters,
                                 @Nonnull ProgressIndicator indicator,
                                 @Nonnull Processor<FoundItemDescriptor<?>> consumer) {
  long start = System.currentTimeMillis();
  try {
    String pattern = parameters.getCompletePattern();
    PsiFileSystemItem absolute = getFileByAbsolutePath(pattern);
    if (absolute != null && !consumer.process(new FoundItemDescriptor<>(absolute, EXACT_MATCH_DEGREE))) {
      return true;
    }

    if (pattern.startsWith("./") || pattern.startsWith(".\\")) {
      parameters = parameters.withCompletePattern(pattern.substring(1));
    }

    if (!processItemsForPattern(base, parameters, consumer, indicator)) {
      return false;
    }
    String fixedPattern = FixingLayoutMatcher.fixLayout(pattern);
    return fixedPattern == null || processItemsForPattern(base, parameters.withCompletePattern(fixedPattern), consumer, indicator);
  }
  finally {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Goto File \"" + parameters.getCompletePattern() + "\" took " + (System.currentTimeMillis() - start) + " ms");
    }
  }
}
 
Example #24
Source File: DefaultChooseByNameItemProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean filterElements(@Nonnull ChooseByNameBase base, @Nonnull FindSymbolParameters parameters, @Nonnull ProgressIndicator indicator, @Nonnull Processor<Object> consumer) {
  return filterElementsWithWeights(base, parameters, indicator, res -> consumer.process(res.getItem()));
}
 
Example #25
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean hasSuggestionsOutsideProject(@Nonnull String pattern, @Nonnull List<List<MatchResult>> groups, @Nonnull DirectoryPathMatcher dirMatcher) {
  return ContainerUtil.exists(groups, group -> !getFilesMatchingPath(FindSymbolParameters.wrap(pattern, myProject, true), group, dirMatcher, indicator).isEmpty());
}
 
Example #26
Source File: UnityScriptGotoClassContributor.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> processor, @Nonnull FindSymbolParameters parameters)
{
	StubIndex.getInstance().processElements(UnityScriptIndexKeys.FILE_BY_NAME_INDEX, name, parameters.getProject(), parameters.getSearchScope(), parameters.getIdFilter(), JSFile.class,
			new Processor<JSFile>()
	{
		@Override
		public boolean process(final JSFile file)
		{
			return processor.process(new FakePsiElement()
			{
				@Override
				public String getName()
				{
					return FileUtil.getNameWithoutExtension(file.getName());
				}

				@Nonnull
				@Override
				public Project getProject()
				{
					return file.getProject();
				}

				@Nullable
				@Override
				public Image getIcon()
				{
					IconDescriptor descriptor = new IconDescriptor(AllIcons.Nodes.Class);
					descriptor.addLayerIcon(Unity3dIcons.Js);
					descriptor.setRightIcon(AllIcons.Nodes.C_public);
					return descriptor.toIcon();
				}

				@Override
				public PsiElement getParent()
				{
					return file;
				}
			});
		}
	});
}
 
Example #27
Source File: ChooseByNameModelEx.java    From consulo with Apache License 2.0 4 votes vote down vote up
default void processNames(@Nonnull Processor<? super String> processor, @Nonnull FindSymbolParameters parameters) {
  processNames(processor, parameters.isSearchInLibraries());
}
 
Example #28
Source File: LSPSymbolContributor.java    From lsp4intellij with Apache License 2.0 4 votes vote down vote up
@Override
public void processElementsWithName(@NotNull String s, @NotNull Processor<? super NavigationItem> processor, @NotNull FindSymbolParameters findSymbolParameters) {
    workspaceSymbolProvider.workspaceSymbols(s, findSymbolParameters.getProject()).stream()
        .filter(ni -> findSymbolParameters.getSearchScope().accept(ni.getFile()))
        .forEach(processor::process);
}
 
Example #29
Source File: DefaultFileNavigationContributor.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean isDirectoryOnlyPattern(@Nonnull FindSymbolParameters parameters) {
  String completePattern = parameters.getCompletePattern();
  return completePattern.endsWith("/") || completePattern.endsWith("\\");
}
 
Example #30
Source File: ContributorsBasedGotoByModel.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Get elements by name from contributors.
 *
 * @param name          a name
 * @param checkBoxState if true, non-project files are considered as well
 * @param pattern       a pattern to use
 * @return a list of navigation items from contributors for
 * which {@link #acceptItem(NavigationItem) returns true.
 */
@Nonnull
@Override
public Object[] getElementsByName(@Nonnull final String name, final boolean checkBoxState, @Nonnull final String pattern) {
  return getElementsByName(name, FindSymbolParameters.wrap(pattern, myProject, checkBoxState), new ProgressIndicatorBase());
}