use of com.intellij.util.concurrency.LockToken in project intellij-community by JetBrains.
the class AbstractTreeUi method getChildrenFor.
//todo [kirillk] temporary consistency check
private Object[] getChildrenFor(final Object element) {
final Ref<Object[]> passOne = new Ref<>();
try (LockToken ignored = acquireLock()) {
execute(new TreeRunnable("AbstractTreeUi.getChildrenFor") {
@Override
public void perform() {
passOne.set(getTreeStructure().getChildElements(element));
}
});
} catch (IndexNotReadyException e) {
warnOnIndexNotReady(e);
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
if (!Registry.is("ide.tree.checkStructure"))
return passOne.get();
final Object[] passTwo = getTreeStructure().getChildElements(element);
final HashSet<Object> two = new HashSet<>(Arrays.asList(passTwo));
if (passOne.get().length != passTwo.length) {
LOG.error("AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" + element);
} else {
for (Object eachInOne : passOne.get()) {
if (!two.contains(eachInOne)) {
LOG.error("AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" + element);
break;
}
}
}
return passOne.get();
}
use of com.intellij.util.concurrency.LockToken in project intellij-community by JetBrains.
the class AbstractTreeUi method releaseNow.
private void releaseNow() {
try (LockToken ignored = acquireLock()) {
myTree.removeTreeExpansionListener(myExpansionListener);
myTree.removeTreeSelectionListener(mySelectionListener);
myTree.removeFocusListener(myFocusListener);
disposeNode(getRootNode());
myElementToNodeMap.clear();
getUpdater().cancelAllRequests();
myWorker.clear();
clearWorkerTasks();
TREE_NODE_WRAPPER.setValue(null);
if (myProgress != null) {
myProgress.cancel();
}
cancelCurrentCleanupTask();
myTree = null;
setUpdater(null);
myTreeStructure = null;
myBuilder.releaseUi();
myBuilder = null;
clearNodeActions();
myDeferredSelections.clear();
myDeferredExpansions.clear();
myYieldingDoneRunnables.clear();
}
}
use of com.intellij.util.concurrency.LockToken in project intellij-community by JetBrains.
the class AbstractTreeUi method update.
private boolean update(@NotNull final NodeDescriptor nodeDescriptor) {
try (LockToken ignored = acquireLock()) {
final AtomicBoolean update = new AtomicBoolean();
execute(new TreeRunnable("AbstractTreeUi.update") {
@Override
public void perform() {
nodeDescriptor.setUpdateCount(nodeDescriptor.getUpdateCount() + 1);
update.set(getBuilder().updateNodeDescriptor(nodeDescriptor));
}
});
return update.get();
} catch (IndexNotReadyException e) {
warnOnIndexNotReady(e);
return false;
}
}
Aggregations