use of com.intellij.navigation.ChooseByNameContributor in project intellij-community by JetBrains.
the class TestsLocationProviderUtil method collectCandidates.
public static List<FileInfo> collectCandidates(final Project project, final String fileName, final boolean includeNonProjectItems) {
final List<FileInfo> filesInfo = new ArrayList<>();
final ChooseByNameContributor[] contributors = Extensions.getExtensions(ChooseByNameContributor.FILE_EP_NAME);
for (ChooseByNameContributor contributor : contributors) {
// let's find files with same name in project and libraries
final NavigationItem[] navigationItems = contributor.getItemsByName(fileName, fileName, project, includeNonProjectItems);
for (NavigationItem navigationItem : navigationItems) {
if (navigationItem instanceof PsiFile) {
final VirtualFile itemFile = ((PsiFile) navigationItem).getVirtualFile();
assert itemFile != null;
filesInfo.add(new FileInfo(itemFile));
}
}
}
return filesInfo;
}
use of com.intellij.navigation.ChooseByNameContributor in project intellij-elixir by KronicDeth.
the class GotoSymbolContributorTest method testIssue472.
/*
* Tests
*/
public void testIssue472() {
myFixture.configureByFile("issue_472.ex");
ChooseByNameContributor[] symbolModelContributors = ChooseByNameRegistry.getInstance().getSymbolModelContributors();
GotoSymbolContributor gotoSymbolContributor = null;
for (ChooseByNameContributor symbolModelContributor : symbolModelContributors) {
if (symbolModelContributor instanceof GotoSymbolContributor) {
gotoSymbolContributor = (GotoSymbolContributor) symbolModelContributor;
}
}
assertNotNull(gotoSymbolContributor);
NavigationItem[] itemsByName = gotoSymbolContributor.getItemsByName("decode_auth_type", "decode_a", myFixture.getProject(), false);
assertEquals(2, itemsByName.length);
assertInstanceOf(itemsByName[0], CallDefinition.class);
CallDefinition callDefinition = (CallDefinition) itemsByName[0];
assertEquals("decode_auth_type", callDefinition.name());
assertInstanceOf(itemsByName[1], CallDefinitionClause.class);
CallDefinitionClause callDefinitionClause = (CallDefinitionClause) itemsByName[1];
assertEquals("decode_auth_type", callDefinitionClause.getName());
}
use of com.intellij.navigation.ChooseByNameContributor in project intellij-community by JetBrains.
the class FilePathCompletionContributor method getAllNames.
private static String[] getAllNames(@NotNull final Project project) {
Set<String> names = new HashSet<>();
final ChooseByNameContributor[] nameContributors = ChooseByNameContributor.FILE_EP_NAME.getExtensions();
for (final ChooseByNameContributor contributor : nameContributors) {
try {
names.addAll(Arrays.asList(contributor.getNames(project, false)));
} catch (ProcessCanceledException ex) {
// index corruption detected, ignore
} catch (Exception ex) {
LOG.error(ex);
}
}
return ArrayUtil.toStringArray(names);
}
use of com.intellij.navigation.ChooseByNameContributor in project intellij-community by JetBrains.
the class ContributorsBasedGotoByModel method processNames.
@Override
public void processNames(final Processor<String> nameProcessor, final boolean checkBoxState) {
long start = System.currentTimeMillis();
List<ChooseByNameContributor> liveContribs = filterDumb(myContributors);
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
Processor<ChooseByNameContributor> processor = new ReadActionProcessor<ChooseByNameContributor>() {
@Override
public boolean processInReadAction(@NotNull ChooseByNameContributor contributor) {
try {
if (!myProject.isDisposed()) {
long contributorStarted = System.currentTimeMillis();
final TIntHashSet filter = new TIntHashSet(1000);
myContributorToItsSymbolsMap.put(contributor, filter);
if (contributor instanceof ChooseByNameContributorEx) {
((ChooseByNameContributorEx) contributor).processNames(s -> {
if (nameProcessor.process(s)) {
filter.add(s.hashCode());
}
return true;
}, FindSymbolParameters.searchScopeFor(myProject, checkBoxState), getIdFilter(checkBoxState));
} else {
String[] names = contributor.getNames(myProject, checkBoxState);
for (String element : names) {
if (nameProcessor.process(element)) {
filter.add(element.hashCode());
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug(contributor + " for " + (System.currentTimeMillis() - contributorStarted));
}
}
} catch (ProcessCanceledException | IndexNotReadyException ex) {
// index corruption detected, ignore
} catch (Exception ex) {
LOG.error(ex);
}
return true;
}
};
if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(liveContribs, indicator, true, processor)) {
throw new ProcessCanceledException();
}
if (indicator != null) {
indicator.checkCanceled();
}
long finish = System.currentTimeMillis();
if (LOG.isDebugEnabled()) {
LOG.debug("processNames(): " + (finish - start) + "ms;");
}
}
use of com.intellij.navigation.ChooseByNameContributor in project intellij-community by JetBrains.
the class GotoClassModel2 method getSeparatorsFromContributors.
public static String[] getSeparatorsFromContributors(ChooseByNameContributor[] contributors) {
final Set<String> separators = new HashSet<>();
separators.add(".");
for (ChooseByNameContributor c : contributors) {
if (c instanceof GotoClassContributor) {
ContainerUtil.addIfNotNull(separators, ((GotoClassContributor) c).getQualifiedNameSeparator());
}
}
return ArrayUtil.toStringArray(separators);
}
Aggregations