private void removeProgress(@NotNull InlineProgressIndicator progress) { synchronized (myOriginals) { if (!myInline2Original.containsKey(progress)) return; final boolean last = myOriginals.size() == 1; final boolean beforeLast = myOriginals.size() == 2; myPopup.removeIndicator(progress); final ProgressIndicatorEx original = removeFromMaps(progress); if (myOriginals.contains(original)) return; if (last) { restoreEmptyStatus(); if (myShouldClosePopupAndOnProcessFinish) { hideProcessPopup(); } } else { if (myPopup.isShowing() || myOriginals.size() > 1) { buildInProcessCount(); } else if (beforeLast) { buildInInlineIndicator(createInlineDelegate(myInfos.get(0), myOriginals.get(0), true)); } else { restoreEmptyStatus(); } } runQuery(); } }
@NotNull public List<Pair<TaskInfo, ProgressIndicator>> getBackgroundProcesses() { synchronized (myOriginals) { if (myOriginals.isEmpty()) return Collections.emptyList(); List<Pair<TaskInfo, ProgressIndicator>> result = new ArrayList<Pair<TaskInfo, ProgressIndicator>>(myOriginals.size()); for (int i = 0; i < myOriginals.size(); i++) { result.add(Pair.<TaskInfo, ProgressIndicator>create(myInfos.get(i), myOriginals.get(i))); } return Collections.unmodifiableList(result); } }
@Nullable private Object findClosestTo(PsiElement path, ArrayList<ObjectWithWeight> paths) { if (path == null || myInitialPsiElement == null) { return paths.get(0).node; } final Set<PsiElement> parents = getAllParents(myInitialPsiElement); ArrayList<ObjectWithWeight> cur = new ArrayList<ObjectWithWeight>(); int max = -1; for (ObjectWithWeight p : paths) { final Object last = ((TreePath) p.node).getLastPathComponent(); final List<PsiElement> elements = new ArrayList<PsiElement>(); final Object object = ((DefaultMutableTreeNode) last).getUserObject(); if (object instanceof FilteringTreeStructure.FilteringNode) { FilteringTreeStructure.FilteringNode node = (FilteringTreeStructure.FilteringNode) object; FilteringTreeStructure.FilteringNode candidate = node; while (node != null) { elements.add(getPsi(node)); node = node.getParentNode(); } final int size = ContainerUtil.intersection(parents, elements).size(); if (size == elements.size() - 1 && size == parents.size() - (myInitialNodeIsLeaf ? 1 : 0) && candidate.children().isEmpty()) { return p.node; } if (size > max) { max = size; cur.clear(); cur.add(p); } else if (size == max) { cur.add(p); } } } Collections.sort( cur, new Comparator<ObjectWithWeight>() { @Override public int compare(ObjectWithWeight o1, ObjectWithWeight o2) { final int i = o1.compareWith(o2); return i != 0 ? i : ((TreePath) o2.node).getPathCount() - ((TreePath) o1.node).getPathCount(); } }); return cur.isEmpty() ? null : cur.get(0).node; }
void hideProcessPopup() { synchronized (myOriginals) { if (!myPopup.isShowing()) return; if (myOriginals.size() == 1) { buildInInlineIndicator(createInlineDelegate(myInfos.get(0), myOriginals.get(0), true)); } else if (!hasProgressIndicators()) { restoreEmptyStatus(); } else { buildInProcessCount(); } myPopup.hide(); } }
private synchronized void assertAllPointersDisposed() { for (Map.Entry<VirtualFilePointerListener, FilePointerPartNode> entry : myPointers.entrySet()) { FilePointerPartNode root = entry.getValue(); ArrayList<FilePointerPartNode> left = new ArrayList<FilePointerPartNode>(); root.getPointersUnder(null, false, "", left); if (!left.isEmpty()) { VirtualFilePointerImpl p = left.get(0).leaf; try { p.throwDisposalError("Not disposed pointer: " + p); } finally { for (FilePointerPartNode pair : left) { VirtualFilePointerImpl pointer = pair.leaf; pointer.dispose(); } } } } synchronized (myContainers) { if (!myContainers.isEmpty()) { VirtualFilePointerContainerImpl container = myContainers.iterator().next(); container.throwDisposalError("Not disposed container"); } } }
public void addEntryPoint(RefElement newEntryPoint, boolean isPersistent) { if (!newEntryPoint.isValid()) return; if (newEntryPoint instanceof RefClass) { RefClass refClass = (RefClass) newEntryPoint; if (refClass.isAnonymous()) { // Anonymous class cannot be an entry point. return; } ArrayList<RefMethod> refConstructors = refClass.getConstructors(); if (refConstructors.size() == 1) { addEntryPoint(refConstructors.get(0), isPersistent); return; } else if (refConstructors.size() > 1) { // Many constructors here. Need to ask user which ones are used for (int i = 0; i < refConstructors.size(); i++) { addEntryPoint((RefMethod) ((ArrayList) refConstructors).get(i), isPersistent); } return; } } if (isPersistent) { myTemporaryEntryPoints.add(newEntryPoint); ((RefElementImpl) newEntryPoint).setEntry(true); } else { if (myPersistentEntryPoints.get(newEntryPoint.getExternalName()) == null) { final SmartRefElementPointerImpl entry = new SmartRefElementPointerImpl(newEntryPoint, true); myPersistentEntryPoints.put(entry.getFQName(), entry); ((RefElementImpl) newEntryPoint).setEntry(true); ((RefElementImpl) newEntryPoint).setPermanentEntry(true); if (entry.isPersistent()) { // do save entry points final EntryPointsManagerImpl entryPointsManager = getInstance(newEntryPoint.getElement().getProject()); if (this != entryPointsManager) { entryPointsManager.addEntryPoint(newEntryPoint, true); } } } } }