use of com.intellij.openapi.util.Condition in project intellij-plugins by JetBrains.
the class DefaultInterceptorRefResolveConverterImpl method fromString.
public InterceptorStack fromString(@Nullable @NonNls final String name, final ConvertContext context) {
if (name == null) {
return null;
}
final Condition<InterceptorStack> nameCondition = interceptorStack -> name.equals(interceptorStack.getName().getStringValue());
final Ref<InterceptorStack> resolveResult = new Ref<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final InterceptorStack result = ContainerUtil.find(strutsPackage.getInterceptorStacks(), nameCondition);
if (result != null) {
resolveResult.set(result);
return false;
}
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(getCurrentStrutsPackage(context), processor);
walker.walkUp();
return resolveResult.get();
}
use of com.intellij.openapi.util.Condition in project intellij-plugins by JetBrains.
the class DartCallHierarchyTreeStructure method collectDeclarations.
public static void collectDeclarations(@Nullable final PsiElement element, @NotNull final List<PsiElement> results) {
if (element != null) {
Condition<PsiElement> isExecutable = object -> {
if (object == null)
return false;
return DartHierarchyUtil.isExecutable(object);
};
PsiElement ref = PsiTreeUtil.findFirstParent(element, isExecutable);
if (ref != null) {
results.add(ref);
}
}
}
use of com.intellij.openapi.util.Condition in project intellij-plugins by JetBrains.
the class PropertyProcessor method writeClassFactory.
private void writeClassFactory(XmlElementValueProvider valueProvider) throws InvalidPropertyException {
if (valueProvider instanceof XmlTagValueProvider) {
XmlTag tag = ((XmlTagValueProvider) valueProvider).getTag();
XmlTag[] subTags = tag.getSubTags();
if (subTags.length > 0) {
processFxComponent(subTags[0], true);
return;
}
}
String className = valueProvider.getTrimmed();
if (writeFxComponentReferenceIfProcessed(className) || writeReferenceIfReferenced(className)) {
return;
}
final JSClass jsClass = valueProvider.getJsClass();
if (jsClass == null) {
throw new InvalidPropertyException(valueProvider.getElement(), "unresolved.class", valueProvider.getTrimmed());
}
final Trinity<Integer, String, Condition<AnnotationBackedDescriptor>> effectiveClassInfo;
final PsiElement parent = jsClass.getNavigationElement().getParent();
if (parent instanceof XmlTag && MxmlUtil.isComponentLanguageTag((XmlTag) parent)) {
// if referenced by inner class name, but inner fx component is not yet processed
if (parent.getContainingFile().equals(valueProvider.getElement().getContainingFile())) {
processFxComponent((XmlTag) parent, false);
return;
} else {
effectiveClassInfo = new Trinity<>(-1, "mx.core.UIComponent", null);
}
} else {
effectiveClassInfo = MxmlUtil.computeEffectiveClass(valueProvider.getElement(), jsClass, mxmlWriter.projectComponentReferenceCounter, false);
}
if (effectiveClassInfo.first == -1) {
if (effectiveClassInfo.second != null) {
if (effectiveClassInfo.second.equals("mx.core.UIComponent")) {
PsiMetaData psiMetaData = valueProvider.getPsiMetaData();
if (psiMetaData != null && psiMetaData.getName().equals("itemRenderer") && MxmlUtil.isPropertyOfSparkDataGroup((AnnotationBackedDescriptor) psiMetaData)) {
className = MxmlUtil.UNKNOWN_ITEM_RENDERER_CLASS_NAME;
} else {
className = MxmlUtil.UNKNOWN_COMPONENT_CLASS_NAME;
}
} else {
className = effectiveClassInfo.second;
}
}
writeNonProjectUnreferencedClassFactory(className);
} else {
writer.documentFactoryReference(effectiveClassInfo.first);
}
}
use of com.intellij.openapi.util.Condition in project intellij-plugins by JetBrains.
the class CreateFlexUnitTestDialog method createUIComponents.
private void createUIComponents() {
final Module module = ModuleUtil.findModuleForPsiElement(myContextClass);
assert module != null;
myPackageCombo = JSReferenceEditor.forPackageName(StringUtil.getPackageName(myContextClass.getQualifiedName()), module.getProject(), null, getTestClassPackageScope(module), RefactoringBundle.message("choose.destination.package"));
final Condition<JSClass> filter = jsClass -> {
final JSAttributeList attributeList = jsClass.getAttributeList();
return !jsClass.isInterface() && attributeList != null && !attributeList.hasModifier(JSAttributeList.ModifierType.FINAL);
};
mySuperClassField = JSReferenceEditor.forClassName("", module.getProject(), null, getSuperClassScope(module), null, filter, JSBundle.message("choose.super.class.title"));
final List<JSMemberInfo> memberInfos = new ArrayList<>();
JSMemberInfo.extractClassMembers(myContextClass, memberInfos, new MemberInfoBase.Filter<JSAttributeListOwner>() {
public boolean includeMember(final JSAttributeListOwner member) {
final JSAttributeList attributeList = member.getAttributeList();
return member instanceof JSFunction && ((JSFunction) member).getKind() != JSFunction.FunctionKind.CONSTRUCTOR && attributeList != null && attributeList.getAccessType() == JSAttributeList.AccessType.PUBLIC;
}
});
myMemberSelectionPanel = new JSMemberSelectionPanel("Generate test methods for:", memberInfos, null);
}
use of com.intellij.openapi.util.Condition in project idea-handlebars by dmarcotte.
the class HbBlockMismatchFix method invoke.
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final int offset = editor.getCaretModel().getOffset();
PsiElement psiElement = file.findElementAt(offset);
if (psiElement == null || !psiElement.isValid())
return;
if (!FileModificationService.getInstance().prepareFileForWrite(psiElement.getContainingFile()))
return;
if (psiElement instanceof PsiWhiteSpace)
psiElement = PsiTreeUtil.prevLeaf(psiElement);
HbBlockMustache blockMustache = (HbBlockMustache) PsiTreeUtil.findFirstParent(psiElement, true, new Condition<PsiElement>() {
@Override
public boolean value(PsiElement psiElement) {
return psiElement instanceof HbBlockMustache;
}
});
if (blockMustache == null) {
return;
}
HbBlockMustache targetBlockMustache = blockMustache;
// ensure we update the open or close mustache for this block appropriately
if (myUpdateOpenMustache != (targetBlockMustache instanceof HbOpenBlockMustache)) {
targetBlockMustache = blockMustache.getPairedElement();
}
HbPath path = PsiTreeUtil.findChildOfType(targetBlockMustache, HbPath.class);
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
if (path != null && document != null) {
final TextRange textRange = path.getTextRange();
document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), myCorrectedName);
}
}
Aggregations