Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
284,900
void (@NotNull PsiTreeChangeEvent event, boolean propertyChange) { if (!(event.getFile() instanceof PsiCodeFragment)) { for (UsageModelTrackerListener listener : myListeners) { listener.modelChanged(propertyChange); } } }
doFire
284,901
void () { }
dispose
284,902
void (@NotNull UsageModelTrackerListener listener, @NotNull Disposable parent) { myListeners.add(listener); Disposer.register(parent, () -> myListeners.remove(listener)); }
addListener
284,903
UsageViewCoroutineScopeProvider (@NotNull Project project) { return project.getService(UsageViewCoroutineScopeProvider.class); }
getInstance
284,904
CoroutineScope () { return myCoroutineScope; }
getCoroutineScope
284,905
void (UsageGroupingRule @NotNull [] rules) { myGroupingRules = rules; }
setGroupingRules
284,906
boolean (@NotNull Usage usage) { return ContainerUtil.and(myFilteringRules, rule -> rule.isVisible(usage, myTargets)); }
isVisible
284,907
UsageViewEx (UsageTarget @NotNull [] targets, Usage @NotNull [] usages, @NotNull UsageViewPresentation presentation, @Nullable Factory<? extends UsageSearcher> usageSearcherFactory) { for (UsageViewFactory factory : UsageViewFactory.EP_NAME.getExtensionList()) { UsageViewEx result = factory.createUsageView(targets, usages, presentation, usageSearcherFactory); if (result != null) { return result; } } UsageViewEx usageView = new UsageViewImpl(myProject, presentation, targets, usageSearcherFactory); if (usages.length != 0) { usageView.appendUsagesInBulk(Arrays.asList(usages)); ProgressManager.getInstance().run(new Task.Modal(myProject, UsageViewBundle.message("progress.title.waiting.for.usages"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { usageView.waitForUpdateRequestsCompletion(); } }); } usageView.setSearchInProgress(false); return usageView; }
createUsageView
284,908
void (@NotNull ProgressIndicator indicator) { usageView.waitForUpdateRequestsCompletion(); }
run
284,909
UsageView (UsageTarget @NotNull [] searchedFor, Usage @NotNull [] foundUsages, @NotNull UsageViewPresentation presentation, @Nullable Factory<? extends UsageSearcher> factory) { UsageViewEx usageView = createUsageView(searchedFor, foundUsages, presentation, factory); showUsageView(usageView, presentation); if (usageView instanceof UsageViewImpl) { showToolWindow(true); UIUtil.invokeLaterIfNeeded(() -> { if (!((UsageViewImpl)usageView).isDisposed()) { ((UsageViewImpl)usageView).expandRoot(); } }); } return usageView; }
showUsages
284,910
UsageView (UsageTarget @NotNull [] searchedFor, Usage @NotNull [] foundUsages, @NotNull UsageViewPresentation presentation) { return showUsages(searchedFor, foundUsages, presentation, null); }
showUsages
284,911
UsageView (UsageTarget @NotNull [] searchFor, @NotNull Factory<? extends UsageSearcher> searcherFactory, @NotNull UsageViewPresentation presentation, @NotNull FindUsagesProcessPresentation processPresentation, @Nullable UsageViewStateListener listener) { if (ApplicationManager.getApplication().isWriteAccessAllowed()) { throw new IllegalStateException("Can't start find usages from under write action. Please consider Application.invokeLater() it instead."); } Supplier<SearchScope> scopeSupplier = getMaxSearchScopeToWarnOfFallingOutOf(searchFor); AtomicReference<UsageViewEx> usageViewRef = new AtomicReference<>(); long start = System.nanoTime(); AtomicLong firstItemFoundTS = new AtomicLong(); AtomicBoolean tooManyUsages = new AtomicBoolean(); Task.Backgroundable task = new Task.Backgroundable(myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) { @Override public void run(@NotNull ProgressIndicator indicator) { SearchScope searchScopeToWarnOfFallingOutOf = ReadAction.compute(() -> scopeSupplier.get()); new SearchForUsagesRunnable(UsageViewManagerImpl.this, UsageViewManagerImpl.this.myProject, usageViewRef, presentation, searchFor, searcherFactory, processPresentation, searchScopeToWarnOfFallingOutOf, listener, firstItemFoundTS, tooManyUsages).run(); } @Override public void onCancel() { reportSearchCompletedToFus(true); super.onCancel(); } @NotNull @Override public NotificationInfo getNotificationInfo() { UsageViewEx usageView = usageViewRef.get(); int count = usageView == null ? 0 : usageView.getUsagesCount(); long duration = reportSearchCompletedToFus(false); String notification = StringUtil.capitalizeWords(UsageViewBundle.message("usages.n", count), true); LOG.debug(notification + " in " + duration + "ms."); return new NotificationInfo("Find Usages", UsageViewBundle.message("notification.title.find.usages.finished"), notification); } private long reportSearchCompletedToFus(boolean isCancelled) { long currentTS = System.nanoTime(); long durationFirstResults = TimeUnit.NANOSECONDS.toMillis(firstItemFoundTS.get() - start); long duration = TimeUnit.NANOSECONDS.toMillis(currentTS - start); PsiElement element = SearchForUsagesRunnable.getPsiElement(searchFor); UsageViewEx view = usageViewRef.get(); Class<? extends PsiElement> targetClass = element != null ? element.getClass() : null; Language language = element != null ? ReadAction.compute(element::getLanguage) : null; SearchScope scope = null; if (element instanceof DataProvider) { scope = UsageView.USAGE_SCOPE.getData((DataProvider)element); } int numberOfUsagesFound = view == null ? 0 : view.getUsagesCount(); UsageViewStatisticsCollector.logSearchFinished(myProject, view, targetClass, scope, language, numberOfUsagesFound, durationFirstResults, duration, tooManyUsages.get(), isCancelled, CodeNavigateSource.FindToolWindow); return duration; } }; ProgressManager.getInstance().run(task); return usageViewRef.get(); }
doSearchAndShow
284,912
void (@NotNull ProgressIndicator indicator) { SearchScope searchScopeToWarnOfFallingOutOf = ReadAction.compute(() -> scopeSupplier.get()); new SearchForUsagesRunnable(UsageViewManagerImpl.this, UsageViewManagerImpl.this.myProject, usageViewRef, presentation, searchFor, searcherFactory, processPresentation, searchScopeToWarnOfFallingOutOf, listener, firstItemFoundTS, tooManyUsages).run(); }
run
284,913
void () { reportSearchCompletedToFus(true); super.onCancel(); }
onCancel
284,914
NotificationInfo () { UsageViewEx usageView = usageViewRef.get(); int count = usageView == null ? 0 : usageView.getUsagesCount(); long duration = reportSearchCompletedToFus(false); String notification = StringUtil.capitalizeWords(UsageViewBundle.message("usages.n", count), true); LOG.debug(notification + " in " + duration + "ms."); return new NotificationInfo("Find Usages", UsageViewBundle.message("notification.title.find.usages.finished"), notification); }
getNotificationInfo
284,915
long (boolean isCancelled) { long currentTS = System.nanoTime(); long durationFirstResults = TimeUnit.NANOSECONDS.toMillis(firstItemFoundTS.get() - start); long duration = TimeUnit.NANOSECONDS.toMillis(currentTS - start); PsiElement element = SearchForUsagesRunnable.getPsiElement(searchFor); UsageViewEx view = usageViewRef.get(); Class<? extends PsiElement> targetClass = element != null ? element.getClass() : null; Language language = element != null ? ReadAction.compute(element::getLanguage) : null; SearchScope scope = null; if (element instanceof DataProvider) { scope = UsageView.USAGE_SCOPE.getData((DataProvider)element); } int numberOfUsagesFound = view == null ? 0 : view.getUsagesCount(); UsageViewStatisticsCollector.logSearchFinished(myProject, view, targetClass, scope, language, numberOfUsagesFound, durationFirstResults, duration, tooManyUsages.get(), isCancelled, CodeNavigateSource.FindToolWindow); return duration; }
reportSearchCompletedToFus
284,916
Supplier<SearchScope> (UsageTarget @NotNull [] searchFor) { UsageTarget target = searchFor.length > 0 ? searchFor[0] : null; DataProvider dataProvider = DataManagerImpl.getDataProviderEx(target); SearchScope scope = dataProvider != null ? UsageView.USAGE_SCOPE.getData(dataProvider) : null; if (scope != null) { return () -> scope; } DataProvider bgtProvider = dataProvider != null ? PlatformCoreDataKeys.BGT_DATA_PROVIDER.getData(dataProvider) : null; return () -> { SearchScope scope2 = bgtProvider != null ? UsageView.USAGE_SCOPE.getData(bgtProvider) : null; if (scope2 != null) return scope2; return GlobalSearchScope.everythingScope(myProject); // by default do not warn of falling out of scope }; }
getMaxSearchScopeToWarnOfFallingOutOf
284,917
void (UsageTarget @NotNull [] searchFor, @NotNull Factory<? extends UsageSearcher> searcherFactory, @NotNull FindUsagesProcessPresentation processPresentation, @NotNull UsageViewPresentation presentation, @Nullable UsageViewStateListener listener) { doSearchAndShow(searchFor, searcherFactory, presentation, processPresentation, listener); }
searchAndShowUsages
284,918
UsageView () { Content content = UsageViewContentManager.getInstance(myProject).getSelectedContent(); if (content != null) { return content.getUserData(USAGE_VIEW_KEY); } return null; }
getSelectedUsageView
284,919
void (@NotNull Project project, @NotNull TooManyUsagesStatus tooManyUsagesStatus, @NotNull ProgressIndicator indicator, @Nullable UsageViewEx usageView, @NotNull Supplier<@NlsContexts.DialogMessage String> messageSupplier, @Nullable Consumer<? super UsageLimitUtil.Result> onUserClicked) { UIUtil.invokeLaterIfNeeded(() -> { if (usageView != null && usageView.searchHasBeenCancelled() || indicator.isCanceled()) { return; } UsageLimitUtil.Result ret = UsageLimitUtil.showTooManyUsagesWarning(project, messageSupplier.get()); if (ret == UsageLimitUtil.Result.ABORT) { if (usageView != null) { usageView.cancelCurrentSearch(); } indicator.cancel(); } tooManyUsagesStatus.userResponded(); if (onUserClicked != null) { onUserClicked.accept(ret); } }); }
showTooManyUsagesWarningLater
284,920
long (@NotNull VirtualFile virtualFile) { return ReadAction.compute(() -> virtualFile.isValid() ? virtualFile.getLength() : -1L); }
getFileLength
284,921
String (long bytes) { long megabytes = bytes / (1024 * 1024); return UsageViewBundle.message("find.file.size.megabytes", Long.toString(megabytes)); }
presentableSize
284,922
boolean (@NotNull Usage usage, @NotNull SearchScope searchScope) { if (searchScope instanceof AcceptEveryUsageScope) return true; return ReadAction.compute(() -> { VirtualFile file; if (usage instanceof PsiElementUsage psiElementUsage) { PsiElement element = psiElementUsage.getElement(); if (element == null) return false; if (searchScope instanceof EverythingGlobalScope || searchScope instanceof ProjectScopeImpl || searchScope instanceof ProjectAndLibrariesScope) return true; file = PsiUtilCore.getVirtualFile(element); } else if (usage instanceof UsageInFile usageInFile){ file = usageInFile.getFile(); } else { return false; } return file != null && isFileInScope(file, searchScope); }); }
isInScope
284,923
boolean (@NotNull VirtualFile file, @NotNull SearchScope searchScope) { if (file instanceof VirtualFileWindow) { file = ((VirtualFileWindow)file).getDelegate(); } file = BackedVirtualFile.getOriginFileIfBacked(file); return searchScope.contains(file); }
isFileInScope
284,924
JComponent () { isDisposed = false; return this; }
createComponent
284,925
void () { isDisposed = true; }
dispose
284,926
void (@Nullable final List<? extends UsageInfo> infos) { AppUIExecutor.onUiThread().withDocumentsCommitted(myProject).expireWith(this).execute(() -> updateLayoutLater(infos)); }
updateLayout
284,927
void (@NotNull List<? extends UsageInfo> infos, @NotNull UsageView usageView) { AppUIExecutor.onUiThread().withDocumentsCommitted(myProject).expireWith(this) .execute(() -> updateLayoutLater(infos, usageView)); }
updateLayout
284,928
void (@NotNull List<? extends UsageInfo> infos, @NotNull UsageView usageView) { updateLayoutLater(infos); }
updateLayoutLater
284,929
int (@NotNull Usage o1, @NotNull Usage o2) { VirtualFile file1 = o1 instanceof UsageInFile ? ((UsageInFile)o1).getFile() : null; VirtualFile file2 = o2 instanceof UsageInFile ? ((UsageInFile)o2).getFile() : null; if (file1 == null || file2 == null) return 0; if (file1.equals(file2)) { return Integer.compare(o1.getNavigationOffset(), o2.getNavigationOffset()); } return VfsUtilCore.compareByPath(file1, file2); }
compareByFileAndOffset
284,930
boolean (@NotNull DefaultMutableTreeNode node) { return node instanceof UsageNode; }
isNodeExclusionAvailable
284,931
boolean (@NotNull DefaultMutableTreeNode node) { return ((UsageNode)node).isDataExcluded(); }
isNodeExcluded
284,932
void (@NotNull DefaultMutableTreeNode node) { Set<Node> nodes = new HashSet<>(); TreeUtil.treeNodeTraverser(node).traverse().filter(Node.class).addAllTo(nodes); collectParentNodes(node, true, nodes); setExcludeNodes(nodes, true, true); }
excludeNode
284,933
void (@NotNull DefaultMutableTreeNode node) { Set<Node> nodes = new HashSet<>(); TreeUtil.treeNodeTraverser(node).traverse().filter(Node.class).addAllTo(nodes); collectParentNodes(node, true, nodes); setExcludeNodes(nodes, true, false); }
excludeNodeSilently
284,934
void (@NotNull DefaultMutableTreeNode node, boolean almostAllChildrenExcluded, @NotNull Set<? super Node> nodes) { TreeNode parent = node.getParent(); if (parent == myRoot || !(parent instanceof GroupNode parentNode)) return; List<Node> otherNodes; synchronized (parentNode) { otherNodes = ContainerUtil.filter(parentNode.getChildren(), n -> n.isExcluded() != almostAllChildrenExcluded); } if (otherNodes.size() == 1 && otherNodes.get(0) == node) { nodes.add(parentNode); collectParentNodes(parentNode, almostAllChildrenExcluded, nodes); } }
collectParentNodes
284,935
void (@NotNull Set<? extends Node> nodes, boolean excluded, boolean updateImmediately) { Set<Usage> affectedUsages = new LinkedHashSet<>(); for (Node node : nodes) { Object userObject = node.getUserObject(); if (userObject instanceof Usage) { affectedUsages.add((Usage)userObject); } node.setExcluded(excluded, edtFireTreeNodesChangedQueue); } if (updateImmediately) { updateImmediatelyNodesUpToRoot(nodes); for (ExcludeListener listener : myExcludeListeners) { listener.fireExcluded(affectedUsages, excluded); } } }
setExcludeNodes
284,936
void (@NotNull DefaultMutableTreeNode node) { Set<Node> nodes = new HashSet<>(); TreeUtil.treeNodeTraverser(node).traverse().filter(Node.class).addAllTo(nodes); collectParentNodes(node, false, nodes); setExcludeNodes(nodes, false, true); }
includeNode
284,937
boolean (boolean isExcludeAction) { return getPresentation().isExcludeAvailable(); }
isActionEnabled
284,938
void (boolean isExcludeAction) { ThreadingAssertions.assertEventDispatchThread(); if (myRootPanel.hasNextOccurence()) { myRootPanel.goNextOccurence(); } }
onDone
284,939
int () { return myUniqueIdentifier; }
getId
284,940
void () { ThreadingAssertions.assertEventDispatchThread(); if (isDisposed()) return; myTree = new Tree(myModel) { { ToolTipManager.sharedInstance().registerComponent(this); } @Override public boolean isRootVisible() { return false; // to avoid re-building model when it calls setRootVisible(true) } @Override public String getToolTipText(MouseEvent e) { TreePath path = getPathForLocation(e.getX(), e.getY()); if (path != null) { if (getCellRenderer() instanceof UsageViewTreeCellRenderer) { return UsageViewTreeCellRenderer.getTooltipFromPresentation(path.getLastPathComponent()); } } return null; } @Override public boolean isPathEditable(@NotNull TreePath path) { return path.getLastPathComponent() instanceof UsageViewTreeModelBuilder.TargetsRootNode; } // hack to avoid quadratic expandAll() @Override public Enumeration<TreePath> getExpandedDescendants(TreePath parent) { return myExpandingCollapsing ? Collections.emptyEnumeration() : super.getExpandedDescendants(parent); } }; myTree.setName("UsageViewTree"); myRootPanel = new MyPanel(myTree); Disposer.register(this, myRootPanel); myTree.setModel(myModel); myRootPanel.setLayout(new BorderLayout()); SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true); myRootPanel.add(toolWindowPanel, BorderLayout.CENTER); toolWindowPanel.setToolbar(createActionsToolbar()); myCentralPanel = new JPanel(new BorderLayout()); setupCentralPanel(); initTree(); toolWindowPanel.setContent(myCentralPanel); myTree.setCellRenderer(myUsageViewTreeCellRenderer); //noinspection SSBasedInspection SwingUtilities.invokeLater(() -> { if (!isDisposed()) { collapseAll(); } }); UsageModelTracker myModelTracker = new UsageModelTracker(getProject()); Disposer.register(this, myModelTracker); myModelTracker.addListener(isPropertyChange -> { if (!isPropertyChange) { myChangesDetected = true; } updateLater(); }, this); if (myPresentation.isShowCancelButton()) { addButtonToLowerPane(this::close, UsageViewBundle.message("usage.view.cancel.button")); } myTree.getSelectionModel().addTreeSelectionListener(__ -> { //noinspection SSBasedInspection SwingUtilities.invokeLater(() -> { if (!isDisposed()) { updateOnSelectionChanged(); myNeedUpdateButtons = true; } }); }); myModel.addTreeModelListener(new TreeModelAdapter() { @Override protected void process(@NotNull TreeModelEvent event, @NotNull EventType type) { myNeedUpdateButtons = true; } }); myTree.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (rulesChanged) { rulesChanged = false; rulesChanged(); } } }); }
initInEDT
284,941
boolean () { return false; // to avoid re-building model when it calls setRootVisible(true) }
isRootVisible
284,942
String (MouseEvent e) { TreePath path = getPathForLocation(e.getX(), e.getY()); if (path != null) { if (getCellRenderer() instanceof UsageViewTreeCellRenderer) { return UsageViewTreeCellRenderer.getTooltipFromPresentation(path.getLastPathComponent()); } } return null; }
getToolTipText
284,943
boolean (@NotNull TreePath path) { return path.getLastPathComponent() instanceof UsageViewTreeModelBuilder.TargetsRootNode; }
isPathEditable
284,944
Enumeration<TreePath> (TreePath parent) { return myExpandingCollapsing ? Collections.emptyEnumeration() : super.getExpandedDescendants(parent); }
getExpandedDescendants
284,945
void (@NotNull TreeModelEvent event, @NotNull EventType type) { myNeedUpdateButtons = true; }
process
284,946
void (FocusEvent e) { if (rulesChanged) { rulesChanged = false; rulesChanged(); } }
focusGained
284,947
UsageViewSettings () { return UsageViewSettings.getInstance(); }
getUsageViewSettings
284,948
Node () { return parentNode; }
getParentNode
284,949
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; NodeChange that = (NodeChange)o; return nodeChangeType == that.nodeChangeType && Objects.equals(parentNode, that.parentNode) && Objects.equals(childNode, that.childNode); }
equals
284,950
int () { return Objects.hash(nodeChangeType, parentNode, childNode); }
hashCode
284,951
void () { ThreadingAssertions.assertEventDispatchThread(); syncModelWithSwingNodes(); fireEventsForChangedNodes(); }
fireEvents
284,952
void () { IntList indicesToFire = new IntArrayList(); List<Node> nodesToFire = new ArrayList<>(); List<Map.Entry<Node, Collection<Node>>> changed; synchronized (fireTreeNodesChangedMap) { changed = new ArrayList<>(fireTreeNodesChangedMap.entrySet()); fireTreeNodesChangedMap.clear(); } for (Map.Entry<Node, Collection<Node>> entry : changed) { Node parentNode = entry.getKey(); Collection<Node> childrenToUpdate = entry.getValue(); for (int i = 0; i < parentNode.getChildCount(); i++) { Node childNode = (Node)parentNode.getChildAt(i); if (childrenToUpdate.contains(childNode)) { nodesToFire.add(childNode); indicesToFire.add(i); } } myModel.fireTreeNodesChanged(parentNode, myModel.getPathToRoot(parentNode), indicesToFire.toIntArray(), nodesToFire.toArray(new Node[0])); indicesToFire.clear(); nodesToFire.clear(); } }
fireEventsForChangedNodes
284,953
void () { List<NodeChange> nodeChanges; synchronized (modelToSwingNodeChanges) { nodeChanges = new ArrayList<>(modelToSwingNodeChanges); modelToSwingNodeChanges.clear(); } IntList indicesToFire = new IntArrayList(); List<Node> nodesToFire = new ArrayList<>(); //first grouping changes by parent node Map<Node, List<NodeChange>> groupByParent = nodeChanges.stream().collect(Collectors.groupingBy(NodeChange::getParentNode)); for (Map.Entry<Node, List<NodeChange>> entry : groupByParent.entrySet()) { Node parentNode = entry.getKey(); synchronized (parentNode) { List<NodeChange> changes = entry.getValue(); List<NodeChange> addedToThisNode = new ArrayList<>(); //removing node for (NodeChange change : changes) { if (change.nodeChangeType.equals(NodeChangeType.REMOVED) || change.nodeChangeType.equals(NodeChangeType.REPLACED)) { GroupNode grandParent = (GroupNode)parentNode.getParent(); int index = grandParent.getSwingChildren().indexOf(parentNode); if (index >= 0) { grandParent.getSwingChildren().remove(parentNode); myModel.nodesWereRemoved(grandParent, new int[]{index}, new Object[]{parentNode}); myModel.fireTreeStructureChanged(grandParent, myModel.getPathToRoot(parentNode), new int[]{index}, new Object[]{parentNode}); if (parentNode instanceof UsageNode) { grandParent.incrementUsageCount(-1); } //if this node was removed than we can skip all the other changes related to it break; } } else { addedToThisNode.add(change); } } //adding children nodes in batch if (!addedToThisNode.isEmpty()) { for (NodeChange change : addedToThisNode) { Node childNode = change.childNode; if (childNode == null) { continue; } synchronized (childNode) { List<Node> swingChildren = ((GroupNode)parentNode).getSwingChildren(); boolean contains = swingChildren.contains(childNode); if (!contains) { nodesToFire.add(childNode); parentNode.insertNewNode(childNode, 0); swingChildren.sort(COMPARATOR); indicesToFire.add(swingChildren.indexOf(change.childNode)); if (childNode instanceof UsageNode) { ((GroupNode)parentNode).incrementUsageCount(1); } } } if (!indicesToFire.isEmpty()) { myModel.fireTreeNodesInserted(parentNode, myModel.getPathToRoot(parentNode), indicesToFire.toIntArray(), nodesToFire.toArray(new Node[0])); indicesToFire.clear(); nodesToFire.clear(); } } } } } }
syncModelWithSwingNodes
284,954
void () { drainQueuedUsageNodes(); setSearchInProgress(false); }
searchFinished
284,955
boolean () { ProgressIndicator progress = associatedProgress; return progress != null && progress.isCanceled(); }
searchHasBeenCancelled
284,956
void () { ProgressIndicator progress = associatedProgress; if (progress != null) { ProgressWrapper.unwrapAll(progress).cancel(); } }
cancelCurrentSearch
284,957
int () { ThreadingAssertions.assertEventDispatchThread(); return TreeUtil.getVisibleRowCount(myTree); }
getVisibleRowCount
284,958
void () { ThreadingAssertions.assertEventDispatchThread(); JScrollPane treePane = ScrollPaneFactory.createScrollPane(myTree); myPreviewSplitter = new OnePixelSplitter(false, 0.5f, 0.1f, 0.9f); myPreviewSplitter.setFirstComponent(treePane); myCentralPanel.add(myPreviewSplitter, BorderLayout.CENTER); updateUsagesContextPanels(); myCentralPanel.add(myAdditionalComponent, BorderLayout.SOUTH); myAdditionalComponent.add(myButtonPanel, BorderLayout.SOUTH); }
setupCentralPanel
284,959
void () { ThreadingAssertions.assertEventDispatchThread(); disposeUsageContextPanels(); if (isPreviewUsages()) { myPreviewSplitter.setProportion(getUsageViewSettings().getPreviewUsagesSplitterProportion()); JBTabbedPane tabbedPane = new JBTabbedPane(SwingConstants.BOTTOM); tabbedPane.setTabComponentInsets(null); UsageContextPanel.Provider[] extensions = UsageContextPanel.Provider.EP_NAME.getExtensions(myProject); List<UsageContextPanel.Provider> myUsageContextPanelProviders = ContainerUtil.filter(extensions, provider -> provider.isAvailableFor(this)); Map<@NlsContexts.TabTitle String, JComponent> components = new LinkedHashMap<>(); for (UsageContextPanel.Provider provider : myUsageContextPanelProviders) { JComponent component; if (myCurrentUsageContextProvider == null || myCurrentUsageContextProvider == provider) { myCurrentUsageContextProvider = provider; UsageContextPanel panel = provider.create(this); myAllUsageContextPanels.add(panel); myCurrentUsageContextPanel = panel; component = myCurrentUsageContextPanel.createComponent(); } else { component = new JLabel(); } components.put(provider.getTabTitle(), component); } JBPanelWithEmptyText panel = new JBPanelWithEmptyText(new BorderLayout()); if (components.size() == 1) { panel.add(components.values().iterator().next(), BorderLayout.CENTER); } else { for (Map.Entry<@NlsContexts.TabTitle String, JComponent> entry : components.entrySet()) { tabbedPane.addTab(entry.getKey(), entry.getValue()); } int index = myUsageContextPanelProviders.indexOf(myCurrentUsageContextProvider); tabbedPane.setSelectedIndex(index); tabbedPane.addChangeListener(e -> { int currentIndex = tabbedPane.getSelectedIndex(); UsageContextPanel.Provider selectedProvider = myUsageContextPanelProviders.get(currentIndex); if (selectedProvider != myCurrentUsageContextProvider) { tabSelected(selectedProvider); UsageViewStatisticsCollector.logTabSwitched(myProject, this); } }); panel.add(tabbedPane, BorderLayout.CENTER); } myPreviewSplitter.setSecondComponent(panel); } else { myPreviewSplitter.setSecondComponent(null); myPreviewSplitter.setProportion(1); } myRootPanel.revalidate(); myRootPanel.repaint(); }
updateUsagesContextPanels
284,960
void (@NotNull UsageContextPanel.Provider provider) { ThreadingAssertions.assertEventDispatchThread(); myCurrentUsageContextProvider = provider; updateUsagesContextPanels(); updateOnSelectionChanged(); }
tabSelected
284,961
void () { ThreadingAssertions.assertEventDispatchThread(); if (!myAllUsageContextPanels.isEmpty()) { saveSplitterProportions(); for (UsageContextPanel panel : myAllUsageContextPanels) { Disposer.dispose(panel); } myCurrentUsageContextPanel = null; myAllUsageContextPanels.clear(); } }
disposeUsageContextPanels
284,962
void () { ThreadingAssertions.assertEventDispatchThread(); myTree.setShowsRootHandles(true); SmartExpander.installOn(myTree); TreeUtil.installActions(myTree); EditSourceOnDoubleClickHandler.install(myTree, fusRunnable); EditSourceOnEnterKeyHandler.install(myTree, fusRunnable); TreeUtil.promiseSelectFirst(myTree); PopupHandler.installPopupMenu(myTree, IdeActions.GROUP_USAGE_VIEW_POPUP, ActionPlaces.USAGE_VIEW_POPUP); myTree.addTreeExpansionListener(new TreeExpansionListener() { @Override public void treeExpanded(TreeExpansionEvent event) { TreePath path = event.getPath(); Object component = path.getLastPathComponent(); if (component instanceof Node node) { if (!myExpandingCollapsing && node.needsUpdate()) { List<Node> toUpdate = new ArrayList<>(); checkNodeValidity(node, path, toUpdate); queueUpdateBulk(toUpdate, EmptyRunnable.getInstance()); } } } @Override public void treeCollapsed(TreeExpansionEvent event) { } }); TreeUIHelper.getInstance().installTreeSpeedSearch(myTree, o -> { Object value = o.getLastPathComponent(); TreeCellRenderer renderer = myTree.getCellRenderer(); if (renderer instanceof UsageViewTreeCellRenderer coloredRenderer) { return coloredRenderer.getPlainTextForNode(value); } return value == null ? null : value.toString(); }, true); }
initTree
284,963
void (TreeExpansionEvent event) { TreePath path = event.getPath(); Object component = path.getLastPathComponent(); if (component instanceof Node node) { if (!myExpandingCollapsing && node.needsUpdate()) { List<Node> toUpdate = new ArrayList<>(); checkNodeValidity(node, path, toUpdate); queueUpdateBulk(toUpdate, EmptyRunnable.getInstance()); } } }
treeExpanded
284,964
void (TreeExpansionEvent event) { }
treeCollapsed
284,965
JComponent () { ThreadingAssertions.assertEventDispatchThread(); DefaultActionGroup group = new DefaultActionGroup() { @Override public void update(@NotNull AnActionEvent e) { super.update(e); myButtonPanel.update(); } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.EDT; } @Override public boolean isDumbAware() { return true; } }; AnAction[] actions = createActions(); for (AnAction action : actions) { if (action != null) { group.add(action); } } return toUsageViewToolbar(group); }
createActionsToolbar
284,966
void (@NotNull AnActionEvent e) { super.update(e); myButtonPanel.update(); }
update
284,967
ActionUpdateThread () { return ActionUpdateThread.EDT; }
getActionUpdateThread
284,968
boolean () { return true; }
isDumbAware
284,969
JComponent (@NotNull DefaultActionGroup group) { ThreadingAssertions.assertEventDispatchThread(); ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.USAGE_VIEW_TOOLBAR, group, false); actionToolbar.setTargetComponent(myRootPanel); return actionToolbar.getComponent(); }
toUsageViewToolbar
284,970
boolean () { return true; }
isPreviewUsageActionEnabled
284,971
void (@NotNull DefaultActionGroup group) { ThreadingAssertions.assertEventDispatchThread(); addFilteringActions(group, true); }
addFilteringActions
284,972
void (@NotNull DefaultActionGroup group, boolean includeExtensionPoints) { if (getPresentation().isMergeDupLinesAvailable()) { MergeSameLineUsagesAction mergeDupLines = new MergeSameLineUsagesAction(); JComponent component = myRootPanel; if (component != null) { mergeDupLines.registerCustomShortcutSet(mergeDupLines.getShortcutSet(), component, this); } group.add(mergeDupLines); } if (includeExtensionPoints) { addFilteringFromExtensionPoints(group); } }
addFilteringActions
284,973
void (@NotNull DefaultActionGroup group) { if (getPresentation().isCodeUsages()) { JComponent component = getComponent(); List<AnAction> actions = usageFilteringRuleActions(myProject, myFilteringRulesState); for (AnAction action : actions) { action.registerCustomShortcutSet(component, this); group.add(action); } } for (UsageFilteringRuleProvider provider : UsageFilteringRuleProvider.EP_NAME.getExtensionList()) { //noinspection deprecation AnAction[] providerActions = provider.createFilteringActions(this); for (AnAction action : providerActions) { group.add(action); } } }
addFilteringFromExtensionPoints
284,974
void () { UsageViewImpl.this.expandAll(); getUsageViewSettings().setExpanded(true); }
expandAll
284,975
boolean () { return true; }
canExpand
284,976
void () { UsageViewImpl.this.collapseAll(); getUsageViewSettings().setExpanded(false); }
collapseAll
284,977
boolean () { return true; }
canCollapse
284,978
boolean () { if (myTargets.length == 0) return false; NavigationItem target = myTargets[0]; return target instanceof ConfigurableUsageTarget; }
canShowSettings
284,979
ConfigurableUsageTarget (UsageTarget @NotNull [] targets) { ConfigurableUsageTarget configurableUsageTarget = null; if (targets.length != 0) { NavigationItem target = targets[0]; if (target instanceof ConfigurableUsageTarget) { configurableUsageTarget = (ConfigurableUsageTarget)target; } } return configurableUsageTarget; }
getConfigurableTarget
284,980
AnAction () { return new PreviewUsageAction(); }
createPreviewAction
284,981
AnAction () { return new ShowSettings(); }
createSettingsAction
284,982
AnAction () { return CommonActionsManager.getInstance().createPrevOccurenceAction(myRootPanel); }
createPreviousOccurrenceAction
284,983
AnAction () { return CommonActionsManager.getInstance().createNextOccurenceAction(myRootPanel); }
createNextOccurrenceAction
284,984
void (@NotNull List<? extends AnAction> actions) { actions.sort((o1, o2) -> Comparing.compare(o1.getTemplateText(), o2.getTemplateText())); }
sortGroupingActions
284,985
boolean () { ThreadingAssertions.assertEventDispatchThread(); return myPresentation.isDetachedMode() || myTree.isShowing(); }
shouldTreeReactNowToRuleChanges
284,986
void () { ThreadingAssertions.assertEventDispatchThread(); if (!shouldTreeReactNowToRuleChanges()) { rulesChanged = true; return; } List<UsageState> states = new ArrayList<>(); if (myTree != null) { captureUsagesExpandState(new TreePath(myTree.getModel().getRoot()), states); } List<Usage> allUsages = new ArrayList<>(myUsageNodes.keySet()); allUsages.sort(USAGE_COMPARATOR_BY_FILE_AND_OFFSET); Set<Usage> excludedUsages = getExcludedUsages(); reset(); myGroupingRules = getActiveGroupingRules(myProject, getUsageViewSettings(), getPresentation()); myBuilder.setGroupingRules(myGroupingRules); myBuilder.setFilteringRules(getActiveFilteringRules(myProject)); for (int i = allUsages.size() - 1; i >= 0; i--) { Usage usage = allUsages.get(i); if (!usage.isValid()) { allUsages.remove(i); continue; } if (usage instanceof MergeableUsage) { ((MergeableUsage)usage).reset(); } } appendUsagesInBulk(allUsages).thenRun(() -> SwingUtilities.invokeLater(() -> { if (isDisposed()) return; if (myTree != null) { excludeUsages(excludedUsages.toArray(Usage.EMPTY_ARRAY)); restoreUsageExpandState(states); updateImmediately(); if (myCentralPanel != null) { updateUsagesContextPanels(); } } })); }
rulesChanged
284,987
void (@NotNull TreePath pathFrom, @NotNull Collection<? super UsageState> states) { ThreadingAssertions.assertEventDispatchThread(); if (!myTree.isExpanded(pathFrom)) { return; } DefaultMutableTreeNode node = (DefaultMutableTreeNode)pathFrom.getLastPathComponent(); int childCount = node.getChildCount(); for (int idx = 0; idx < childCount; idx++) { TreeNode child = node.getChildAt(idx); if (child instanceof UsageNode) { Usage usage = ((UsageNode)child).getUsage(); states.add(new UsageState(usage, myTree.getSelectionModel().isPathSelected(pathFrom.pathByAddingChild(child)))); } else { captureUsagesExpandState(pathFrom.pathByAddingChild(child), states); } } }
captureUsagesExpandState
284,988
void (@NotNull Collection<? extends UsageState> states) { ThreadingAssertions.assertEventDispatchThread(); //always expand the last level group DefaultMutableTreeNode root = (DefaultMutableTreeNode)myTree.getModel().getRoot(); for (int i = root.getChildCount() - 1; i >= 0; i--) { DefaultMutableTreeNode child = (DefaultMutableTreeNode)root.getChildAt(i); if (child instanceof GroupNode) { TreePath treePath = new TreePath(child.getPath()); myTree.expandPath(treePath); } } myTree.getSelectionModel().clearSelection(); for (UsageState usageState : states) { usageState.restore(); } }
restoreUsageExpandState
284,989
void () { doExpandingCollapsing(() -> TreeUtil.expandAll(myTree)); }
expandAll
284,990
void (int levels) { doExpandingCollapsing(() -> TreeUtil.expand(myTree, levels)); }
expandTree
284,991
void (@NotNull Runnable task) { if (isDisposed()) return; ThreadingAssertions.assertEventDispatchThread(); fireEvents(); // drain all remaining insertion events in the queue myExpandingCollapsing = true; try { task.run(); } finally { myExpandingCollapsing = false; } }
doExpandingCollapsing
284,992
void () { doExpandingCollapsing(() -> { TreeUtil.collapseAll(myTree, 3); myTree.expandRow(0); }); }
collapseAll
284,993
void () { expandTree(1); }
expandRoot
284,994
void () { ThreadingAssertions.assertEventDispatchThread(); // can be null during ctr execution if (myTree != null) { myTree.requestFocusInWindow(); } }
select
284,995
Project () { return myProject; }
getProject
284,996
KeyboardShortcut (UsageTarget @NotNull [] targets) { ConfigurableUsageTarget configurableTarget = getConfigurableTarget(targets); return configurableTarget == null ? UsageViewUtil.getShowUsagesWithSettingsShortcut() : configurableTarget.getShortcut(); }
getShowUsagesWithSettingsShortcut
284,997
void (@NotNull ProgressIndicator indicator) { associatedProgress = indicator; }
associateProgress
284,998
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
284,999
void (@NotNull AnActionEvent e) { e.getPresentation().setEnabled(e.getData(CommonDataKeys.EDITOR) == null); if (getTemplatePresentation().getDescription() == null) { ConfigurableUsageTarget target = getConfigurableTarget(myTargets); Supplier<String> description = null; if (target != null) { try { description = UsageViewBundle.messagePointer( "action.ShowSettings.show.settings.for.description", target.getLongDescriptiveName()); } catch (IndexNotReadyException ignored) { } } if (description == null) { description = UsageViewBundle.messagePointer("action.ShowSettings.show.find.usages.settings.dialog.description"); } getTemplatePresentation().setDescription(description); e.getPresentation().setDescription(description); } }
update