use of com.intellij.usages.impl.UsageViewImpl in project intellij-community by JetBrains.
the class BackgroundUpdaterTask method updateComponent.
public boolean updateComponent(final PsiElement element, @Nullable final Comparator comparator) {
final UsageView view = myUsageView.get();
if (view != null && !((UsageViewImpl) view).isDisposed()) {
ApplicationManager.getApplication().runReadAction(() -> view.appendUsage(new UsageInfo2UsageAdapter(new UsageInfo(element))));
return true;
}
if (myCanceled)
return false;
final JComponent content = myPopup.getContent();
if (content == null || myPopup.isDisposed())
return false;
synchronized (lock) {
if (myData.contains(element))
return true;
myData.add(element);
if (comparator != null) {
Collections.sort(myData, comparator);
}
}
myAlarm.addRequest(() -> {
myAlarm.cancelAllRequests();
refreshModelImmediately();
}, 200, ModalityState.stateForComponent(content));
return true;
}
use of com.intellij.usages.impl.UsageViewImpl in project intellij-community by JetBrains.
the class FindUtil method showInUsageView.
@Nullable
public static UsageView showInUsageView(@Nullable PsiElement sourceElement, @NotNull PsiElement[] targets, @NotNull String title, @NotNull final Project project) {
if (targets.length == 0)
return null;
final UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setCodeUsagesString(title);
presentation.setTabName(title);
presentation.setTabText(title);
UsageTarget[] usageTargets = sourceElement == null ? UsageTarget.EMPTY_ARRAY : new UsageTarget[] { new PsiElement2UsageTargetAdapter(sourceElement) };
PsiElement[] primary = sourceElement == null ? PsiElement.EMPTY_ARRAY : new PsiElement[] { sourceElement };
UsageView view = UsageViewManager.getInstance(project).showUsages(usageTargets, Usage.EMPTY_ARRAY, presentation);
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(project);
List<SmartPsiElementPointer> pointers = ContainerUtil.map(targets, smartPointerManager::createSmartPsiElementPointer);
// usage view will load document/AST so still referencing all these PSI elements might lead to out of memory
//noinspection UnusedAssignment
targets = PsiElement.EMPTY_ARRAY;
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Updating Usage View ...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
for (final SmartPsiElementPointer pointer : pointers) {
if (((UsageViewImpl) view).isDisposed())
break;
ApplicationManager.getApplication().runReadAction(() -> {
final PsiElement target = pointer.getElement();
if (target != null) {
view.appendUsage(UsageInfoToUsageConverter.convert(primary, new UsageInfo(target)));
}
});
}
UIUtil.invokeLaterIfNeeded(((UsageViewImpl) view)::expandAll);
}
});
return view;
}
use of com.intellij.usages.impl.UsageViewImpl in project intellij-community by JetBrains.
the class RerunSearchAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
UsageView usageView = UsageView.USAGE_VIEW_KEY.getData(e.getDataContext());
boolean enabled = usageView instanceof UsageViewImpl && ((UsageViewImpl) usageView).canPerformReRun();
e.getPresentation().setEnabled(enabled);
}
Aggregations