use of com.intellij.find.impl.FindManagerImpl in project intellij-community by JetBrains.
the class PsiElement2UsageTargetAdapter method highlightUsages.
@Override
public void highlightUsages(@NotNull PsiFile file, @NotNull Editor editor, boolean clearHighlights) {
PsiElement target = getElement();
if (file instanceof PsiCompiledFile)
file = ((PsiCompiledFile) file).getDecompiledPsiFile();
Project project = target.getProject();
final FindUsagesManager findUsagesManager = ((FindManagerImpl) FindManager.getInstance(project)).getFindUsagesManager();
final FindUsagesHandler handler = findUsagesManager.getFindUsagesHandler(target, true);
// in case of injected file, use host file to highlight all occurrences of the target in each injected file
PsiFile context = InjectedLanguageManager.getInstance(project).getTopLevelFile(file);
SearchScope searchScope = new LocalSearchScope(context);
Collection<PsiReference> refs = handler == null ? ReferencesSearch.search(target, searchScope, false).findAll() : handler.findReferencesToHighlight(target, searchScope);
new HighlightUsagesHandler.DoHighlightRunnable(new ArrayList<>(refs), project, target, editor, context, clearHighlights).run();
}
use of com.intellij.find.impl.FindManagerImpl in project intellij-community by JetBrains.
the class FindInProjectManager method startFindInProject.
public void startFindInProject(@NotNull FindModel findModel) {
if (findModel.getDirectoryName() != null && FindInProjectUtil.getDirectory(findModel) == null) {
return;
}
com.intellij.usages.UsageViewManager manager = com.intellij.usages.UsageViewManager.getInstance(myProject);
if (manager == null)
return;
final FindManager findManager = FindManager.getInstance(myProject);
findManager.getFindInProjectModel().copyFrom(findModel);
final FindModel findModelCopy = findModel.clone();
final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(FindSettings.getInstance().isShowResultsInSeparateView(), findModelCopy);
final boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation);
ConfigurableUsageTarget usageTarget = new FindInProjectUtil.StringUsageTarget(myProject, findModel);
((FindManagerImpl) FindManager.getInstance(myProject)).getFindUsagesManager().addToHistory(usageTarget);
manager.searchAndShowUsages(new UsageTarget[] { usageTarget }, () -> processor -> {
myIsFindInProgress = true;
try {
Processor<UsageInfo> consumer = info -> {
Usage usage = UsageInfo2UsageAdapter.CONVERTER.fun(info);
usage.getPresentation().getIcon();
return processor.process(usage);
};
FindInProjectUtil.findUsages(findModelCopy, myProject, consumer, processPresentation);
} finally {
myIsFindInProgress = false;
}
}, processPresentation, presentation, null);
}
Aggregations