private static ElementFilter createAnnotationFilter(PsiElement position) { OrFilter orFilter = new OrFilter(ElementClassFilter.CLASS, ElementClassFilter.PACKAGE_FILTER, new AndFilter(new ClassFilter(PsiField.class), new ModifierFilter(PsiModifier.STATIC, PsiModifier.FINAL))); if(psiElement().insideStarting(psiNameValuePair()).accepts(position)) { orFilter.addFilter(new ClassFilter(PsiAnnotationMethod.class) { @Override public boolean isAcceptable(Object element, PsiElement context) { return element instanceof PsiAnnotationMethod && PsiUtil.isAnnotationMethod((PsiElement) element); } }); } return orFilter; }
@NotNull @Override protected ElementFilter compute() { return new OrFilter(new AndFilter(new LeftNeighbour(new OrFilter(new AndFilter(new TextFilter("{", "}", ";", ":", "else"), new NotFilter(new SuperParentFilter(new ClassFilter (PsiAnnotation.class)))), new ElementFilter() { @Override public boolean isAcceptable(Object element, @Nullable PsiElement context) { return ((PsiElement) element).getText().endsWith("*/"); } @Override public boolean isClassAcceptable(Class hintClass) { return true; } }, new ClassFilter(OuterLanguageElement.class), new AndFilter(new TextFilter(")"), new NotFilter(new OrFilter(new ParentElementFilter(new ClassFilter(PsiExpressionList.class)), new ParentElementFilter(new ClassFilter(PsiParameterList.class)), new ParentElementFilter(new ClassFilter(PsiTypeCastExpression.class))))))), new NotFilter(new TextFilter("."))), START_OF_CODE_FRAGMENT); }
@Nullable private static ElementFilter getClassReferenceFilter(PsiElement element) { //throw new foo if (AFTER_THROW_NEW.accepts(element)) { return THROWABLES_FILTER; } //throws list PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class); if (method != null && PsiTreeUtil.isAncestor(method.getThrowsList(), element, true)) { return THROWABLES_FILTER; } //new xxx.yyy if (psiElement().afterLeaf(psiElement().withText(".")).withSuperParent(2, psiElement(PsiNewExpression.class)).accepts(element)) { if (((PsiNewExpression)element.getParent().getParent()).getClassReference() == element.getParent()) { PsiType[] types = ExpectedTypesGetter.getExpectedTypes(element, false); return new OrFilter(ContainerUtil.map2Array(types, ElementFilter.class, new Function<PsiType, ElementFilter>() { @Override public ElementFilter fun(PsiType type) { return new AssignableFromFilter(type); } })); } } return null; }
@Override protected ElementFilter createXmlEntityCompletionFilter() { if (isCaseInsensitive()) { return new AndFilter( new OrFilter ( new XmlTokenTypeFilter(XmlTokenType.XML_DATA_CHARACTERS), new XmlTokenTypeFilter(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) ), new TextContainFilter("&") ); } return super.createXmlEntityCompletionFilter(); }
@NotNull private static MembersMap buildAllMaps(@NotNull PsiClass psiClass) { final List<Pair<PsiMember, PsiSubstitutor>> classes = new ArrayList<Pair<PsiMember, PsiSubstitutor>>(); final List<Pair<PsiMember, PsiSubstitutor>> fields = new ArrayList<Pair<PsiMember, PsiSubstitutor>>(); final List<Pair<PsiMember, PsiSubstitutor>> methods = new ArrayList<Pair<PsiMember, PsiSubstitutor>>(); FilterScopeProcessor<MethodCandidateInfo> processor = new FilterScopeProcessor<MethodCandidateInfo>( new OrFilter(ElementClassFilter.METHOD, ElementClassFilter.FIELD, ElementClassFilter.CLASS)) { @Override protected void add(PsiElement element, PsiSubstitutor substitutor) { if (element instanceof PsiMethod) { methods.add(Pair.create((PsiMember)element, substitutor)); } else if (element instanceof PsiField) { fields.add(Pair.create((PsiMember)element, substitutor)); } else if (element instanceof PsiClass) { classes.add(Pair.create((PsiMember)element, substitutor)); } } }; processDeclarationsInClassNotCached(psiClass, processor, ResolveState.initial(), null, null, psiClass, false, PsiUtil.getLanguageLevel(psiClass)); MembersMap result = new MembersMap(MemberType.class); result.put(MemberType.CLASS, generateMapByList(classes)); result.put(MemberType.METHOD, generateMapByList(methods)); result.put(MemberType.FIELD, generateMapByList(fields)); return result; }
protected ElementFilter createXmlEntityCompletionFilter() { if (isCaseInsensitive()) { return new AndFilter( new OrFilter ( new XmlTokenTypeFilter(XmlTokenType.XML_DATA_CHARACTERS), new XmlTokenTypeFilter(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) ), new TextContainFilter("&") ); } return super.createXmlEntityCompletionFilter(); }
@Override public void contributeMetaData(final MetaDataRegistrar registrar) { { registrar.registerMetaData(new AndFilter(new NamespaceFilter(XmlUtil.SCHEMA_URIS), new ClassFilter(XmlDocument.class)), SchemaNSDescriptor.class); registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("schema")), SchemaNSDescriptor.class); } { registrar.registerMetaData(new OrFilter(new AndFilter(new ContentFilter(new OrFilter(new ClassFilter(XmlElementDecl.class), new ClassFilter(XmlEntityDecl.class), new ClassFilter (XmlConditionalSection.class), new ClassFilter(XmlEntityRef.class))), new ClassFilter(XmlDocument.class)), new ClassFilter(XmlMarkupDecl.class)), XmlNSDescriptorImpl.class); } { registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("element")), XmlElementDescriptorImpl.class); } { registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("attribute")), XmlAttributeDescriptorImpl.class); } { registrar.registerMetaData(new ClassFilter(XmlElementDecl.class), com.intellij.xml.impl.dtd.XmlElementDescriptorImpl.class); } { registrar.registerMetaData(new ClassFilter(XmlAttributeDecl.class), com.intellij.xml.impl.dtd.XmlAttributeDescriptorImpl.class); } { registrar.registerMetaData(new AndFilter(new ClassFilter(XmlDocument.class), new TargetNamespaceFilter(XmlUtil.XHTML_URI), new NamespaceFilter(XmlUtil.SCHEMA_URIS)), RelaxedHtmlFromSchemaNSDescriptor.class); } { registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("complexType", "simpleType", "group", "attributeGroup")), NamedObjectDescriptor.class); } }
@Nullable private static ElementFilter getClassReferenceFilter(final PsiElement element, final boolean inRefList) { //throw new foo if(AFTER_THROW_NEW.accepts(element)) { return THROWABLES_FILTER; } //new xxx.yyy if(psiElement().afterLeaf(psiElement().withText(".")).withSuperParent(2, psiElement(PsiNewExpression.class)).accepts(element)) { if(((PsiNewExpression) element.getParent().getParent()).getClassReference() == element.getParent()) { PsiType[] types = ExpectedTypesGetter.getExpectedTypes(element, false); return new OrFilter(ContainerUtil.map2Array(types, ElementFilter.class, (Function<PsiType, ElementFilter>) type -> new AssignableFromFilter(type))); } } // extends/implements/throws if(inRefList) { return new ElementExtractorFilter(new ElementFilter() { @Override public boolean isAcceptable(Object aClass, @Nullable PsiElement context) { return aClass instanceof PsiClass && ReferenceListWeigher.INSTANCE.getApplicability((PsiClass) aClass, element) != ReferenceListWeigher.ReferenceListApplicability.inapplicable; } @Override public boolean isClassAcceptable(Class hintClass) { return true; } }); } return null; }
@NotNull @Override protected ElementFilter compute() { return new OrFilter(new AfterElementFilter(new TextFilter("{"))); }