use of com.intellij.openapi.util.Condition in project intellij-plugins by JetBrains.
the class LibraryManager method getOrCreateFlexLibrarySet.
private FlexLibrarySet getOrCreateFlexLibrarySet(LibraryCollector libraryCollector, AssetCounter assetCounter) throws InitException {
final String key = createKey(libraryCollector.sdkLibraries, true);
FlexLibrarySet flexLibrarySet = (FlexLibrarySet) librarySets.get(key);
if (flexLibrarySet == null) {
final Set<CharSequence> globalDefinitions = getGlobalDefinitions(libraryCollector.getGlobalLibrary());
final Condition<String> globalContains = name -> globalDefinitions.contains(name);
final SortResult sortResult = sortLibraries(new LibrarySorter(new FlexDefinitionProcessor(libraryCollector.getFlexSdkVersion()), new FlexDefinitionMapProcessor(libraryCollector.getFlexSdkVersion(), globalContains)), libraryCollector, globalContains, key, true);
flexLibrarySet = new FlexLibrarySet(sortResult, null, new ContainsCondition(globalDefinitions, sortResult.definitionMap), assetCounter, libraryCollector.getFlexSdkVersion());
registerLibrarySet(key, flexLibrarySet);
}
return flexLibrarySet;
}
use of com.intellij.openapi.util.Condition in project intellij-plugins by JetBrains.
the class MxmlWriter method write.
@Nullable
public Pair<ProjectComponentReferenceCounter, List<RangeMarker>> write(XmlFile psiFile) throws IOException {
document = MxmlUtil.getDocumentAndWaitIfNotCommitted(psiFile);
final AccessToken token = ReadAction.start();
try {
VirtualFile virtualFile = psiFile.getVirtualFile();
LOG.assertTrue(virtualFile != null);
problemsHolder.setCurrentFile(virtualFile);
XmlTag tag = psiFile.getRootTag();
XmlElementDescriptor untypedDescriptor = tag == null ? null : tag.getDescriptor();
final ClassBackedElementDescriptor descriptor;
if (untypedDescriptor instanceof ClassBackedElementDescriptor) {
descriptor = (ClassBackedElementDescriptor) untypedDescriptor;
} else {
return null;
}
final Trinity<Integer, String, Condition<AnnotationBackedDescriptor>> effectiveClassInfo;
try {
PsiElement declaration = descriptor.getDeclaration();
if (declaration == null) {
return null;
}
effectiveClassInfo = MxmlUtil.computeEffectiveClass(tag, declaration, projectComponentReferenceCounter, true);
} catch (InvalidPropertyException e) {
problemsHolder.add(e);
return null;
}
if (effectiveClassInfo.first == -1) {
out.write(Amf3Types.OBJECT);
writer.mxmlObjectHeader(effectiveClassInfo.second == null ? descriptor.getQualifiedName() : effectiveClassInfo.second);
} else {
writer.documentReference(effectiveClassInfo.first);
out.allocateClearShort();
}
processElements(tag, null, false, -1, out.size() - 2, true, effectiveClassInfo.third);
writer.endObject();
if (stateWriter != null) {
stateWriter.write();
hasStates = false;
} else {
out.write(0);
}
injectedASWriter.write();
writer.writeMessageHeader(projectComponentReferenceCounter);
return Pair.create(projectComponentReferenceCounter, rangeMarkers);
} finally {
token.finish();
problemsHolder.setCurrentFile(null);
writer.resetAfterMessage();
}
}
use of com.intellij.openapi.util.Condition in project intellij-community by JetBrains.
the class UpdaterTreeState method processAjusted.
private ActionCallback processAjusted(final Map<Object, Condition> adjusted, final Set<Object> originallySelected) {
final ActionCallback result = new ActionCallback();
final Set<Object> allSelected = myUi.getSelectedElements();
Set<Object> toSelect = new HashSet<>();
for (Map.Entry<Object, Condition> entry : adjusted.entrySet()) {
if (entry.getValue().value(entry.getKey()))
continue;
for (final Object eachSelected : allSelected) {
if (isParentOrSame(entry.getKey(), eachSelected))
continue;
toSelect.add(entry.getKey());
}
if (allSelected.isEmpty()) {
toSelect.add(entry.getKey());
}
}
final Object[] newSelection = ArrayUtil.toObjectArray(toSelect);
if (newSelection.length > 0) {
myUi._select(newSelection, new TreeRunnable("UpdaterTreeState.processAjusted") {
@Override
public void perform() {
final Set<Object> hangByParent = new HashSet<>();
processUnsuccessfulSelections(newSelection, o -> {
if (myUi.isInStructure(o) && !adjusted.get(o).value(o)) {
hangByParent.add(o);
} else {
addAdjustedSelection(o, adjusted.get(o), null);
}
return null;
}, originallySelected);
processHangByParent(hangByParent).notify(result);
}
}, false, true, true);
} else {
result.setDone();
}
return result;
}
use of com.intellij.openapi.util.Condition in project intellij-community by JetBrains.
the class XDebuggerInstanceTreeCreator method createTree.
@NotNull
@Override
public Tree createTree(@NotNull Pair<XInstanceEvaluator, String> descriptor) {
final XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
final XValueNodeImpl root = new XValueNodeImpl(tree, null, descriptor.getSecond(), new InstanceEvaluatorTreeRootValue(descriptor.getFirst(), descriptor.getSecond()));
tree.setRoot(root, false);
Condition<TreeNode> visibleRootCondition = node -> node.getParent() == root;
tree.expandNodesOnLoad(visibleRootCondition);
tree.selectNodeOnLoad(visibleRootCondition);
return tree;
}
use of com.intellij.openapi.util.Condition in project intellij-community by JetBrains.
the class CommandProcessor method run.
private boolean run(boolean synchronously) {
synchronized (myLock) {
final CommandGroup commandGroup = getNextCommandGroup();
if (commandGroup == null || commandGroup.isEmpty())
return false;
final Condition conditionForGroup = commandGroup.getExpireCondition();
final FinalizableCommand command = commandGroup.takeNextCommand();
myCommandCount--;
Condition expire = command.getExpireCondition() != null ? command.getExpireCondition() : conditionForGroup;
if (expire == null)
expire = ApplicationManager.getApplication().getDisposed();
if (expire.value(null))
return true;
if (LOG.isDebugEnabled()) {
LOG.debug("CommandProcessor.run " + command);
}
if (synchronously) {
command.run();
return true;
}
// max. I'm not actually quite sure this should have NON_MODAL modality but it should
// definitely have some since runnables in command list may (and do) request some PSI activity
final boolean queueNext = myCommandCount > 0;
Application application = ApplicationManager.getApplication();
ModalityState modalityState = Registry.is("ide.perProjectModality") ? ModalityState.current() : ModalityState.NON_MODAL;
application.getInvokator().invokeLater(command, modalityState, expire).doWhenDone(() -> {
if (queueNext) {
run(false);
}
});
return true;
}
}
Aggregations