本文整理汇总了Java中com.intellij.psi.filters.ElementFilter类的典型用法代码示例。如果您正苦于以下问题:Java ElementFilter类的具体用法?Java ElementFilter怎么用?Java ElementFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ElementFilter类属于com.intellij.psi.filters包,在下文中一共展示了ElementFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recursionFilter
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
@Nullable
static ElementFilter recursionFilter(PsiElement element) {
if (PsiJavaPatterns.psiElement().afterLeaf(PsiKeyword.RETURN).inside(PsiReturnStatement.class).accepts(element)) {
return new ExcludeDeclaredFilter(ElementClassFilter.METHOD);
}
if (PsiJavaPatterns.psiElement().inside(
StandardPatterns.or(
PsiJavaPatterns.psiElement(PsiAssignmentExpression.class),
PsiJavaPatterns.psiElement(PsiVariable.class))).
andNot(PsiJavaPatterns.psiElement().afterLeaf(".")).accepts(element)) {
return new AndFilter(new ExcludeSillyAssignment(),
new ExcludeDeclaredFilter(new ClassFilter(PsiVariable.class)));
}
return null;
}
示例2: hasLanguageLevel
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
public static FilterPattern hasLanguageLevel(@NotNull final Processor<LanguageLevel> processor) {
return new FilterPattern(new ElementFilter() {
@Override
public boolean isAcceptable(Object element, @Nullable PsiElement context) {
if (element instanceof PsiElement) {
return processor.process(LanguageLevel.forElement((PsiElement)element));
}
return false;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return true;
}
});
}
示例3: contributeMetaData
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
@Override
public void contributeMetaData(MetaDataRegistrar registrar) {
registrar.registerMetaData(new ElementFilter() {
@Override
public boolean isAcceptable(Object element, PsiElement context) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag)element;
final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
if (domElement != null) {
return domElement.getGenericInfo().getNameDomElement(domElement) != null;
}
}
return false;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return XmlTag.class.isAssignableFrom(hintClass);
}
}, DomMetaData.class);
}
示例4: getIdForFilter
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
public ElementFilter getIdForFilter() {
return new ElementFilter() {
@Override
public boolean isAcceptable(Object element, PsiElement context) {
final PsiElement grandParent = ((PsiElement)element).getParent().getParent();
if (grandParent instanceof XmlTag) {
final XmlTag tag = (XmlTag)grandParent;
if (!tag.getNamespacePrefix().isEmpty()) {
return true;
}
}
return false;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return true;
}
};
}
示例5: registerXmlAttributeValueReferenceProvider
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
public static void registerXmlAttributeValueReferenceProvider(PsiReferenceRegistrar registrar,
@Nullable @NonNls String[] attributeNames,
@Nullable ElementFilter elementFilter,
boolean caseSensitive,
@NotNull PsiReferenceProvider provider,
double priority) {
if (attributeNames == null) {
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().and(new FilterPattern(elementFilter)), provider, priority);
return;
}
final StringPattern namePattern = caseSensitive
? StandardPatterns.string().oneOf(attributeNames)
: StandardPatterns.string().oneOfIgnoreCase(attributeNames);
registrar
.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withLocalName(namePattern).and(new FilterPattern(elementFilter)), provider,
priority);
}
示例6: registerXmlTagReferenceProvider
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
public static void registerXmlTagReferenceProvider(PsiReferenceRegistrar registrar,
@NonNls String[] names,
@Nullable ElementFilter elementFilter,
boolean caseSensitive,
@NotNull PsiReferenceProvider provider) {
if (names == null) {
registrar.registerReferenceProvider(XmlPatterns.xmlTag().and(new FilterPattern(elementFilter)), provider,
PsiReferenceRegistrar.DEFAULT_PRIORITY);
return;
}
final StringPattern namePattern =
caseSensitive ? StandardPatterns.string().oneOf(names) : StandardPatterns.string().oneOfIgnoreCase(names);
registrar.registerReferenceProvider(XmlPatterns.xmlTag().withLocalName(namePattern).and(new FilterPattern(elementFilter)), provider,
PsiReferenceRegistrar.DEFAULT_PRIORITY);
}
示例7: createAttributeValueCompletionFilter
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
@Override
protected ElementFilter createAttributeValueCompletionFilter() {
return new ElementFilter() {
@Override
public boolean isAcceptable(Object element, PsiElement context) {
if (isStyleAttributeContext(context)) return false;
if ( isScriptContext((PsiElement)element) ) return false;
return true;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return true;
}
};
}
示例8: registerReferenceProviders
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
public void registerReferenceProviders(@NotNull final PsiReferenceRegistrar registrar) {
final JavaClassListReferenceProvider classListProvider = new JavaClassListReferenceProvider();
registrar.registerReferenceProvider(xmlAttributeValue(), classListProvider, PsiReferenceRegistrar.LOWER_PRIORITY);
registrar.registerReferenceProvider(xmlTag(), classListProvider, PsiReferenceRegistrar.LOWER_PRIORITY);
final PsiReferenceProvider filePathReferenceProvider = new FilePathReferenceProvider();
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class).and(new FilterPattern(new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
PsiLiteralExpression literalExpression = (PsiLiteralExpression) context;
final Map<String, Object> annotationParams = new HashMap<String, Object>();
annotationParams.put(AnnotationUtil.PROPERTY_KEY_RESOURCE_BUNDLE_PARAMETER, null);
return !JavaI18nUtil.mustBePropertyKey(context.getProject(), literalExpression, annotationParams);
}
public boolean isClassAcceptable(Class hintClass) {
return true;
}
})), filePathReferenceProvider);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiDocToken.class),
CommentsReferenceContributor.COMMENTS_REFERENCE_PROVIDER_TYPE.getProvider());
}
示例9: isPossibleHere
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
@NotNull
private ElementPattern isPossibleHere(@NotNull final String keyword) {
return new FilterPattern(new ElementFilter() {
public boolean isAcceptable(final Object element, final PsiElement context) {
final CompletionParameters parameters = getCompletionParameters(element);
if (parameters == null) return false;
final PsiElement dummyElement = createDummyElement(parameters, keyword, false);
return dummyElement != null && isCorrect(dummyElement);
}
public boolean isClassAcceptable(@NotNull final Class hintClass) {
return true;
}
});
}
示例10: suggestQualifierItems
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
private static Set<LookupElement> suggestQualifierItems(CompletionParameters parameters,
PsiJavaCodeReferenceElement qualifier,
ElementFilter filter) {
String referenceName = qualifier.getReferenceName();
if (referenceName == null) {
return Collections.emptySet();
}
PrefixMatcher qMatcher = new CamelHumpMatcher(referenceName);
Set<LookupElement> plainVariants =
JavaSmartCompletionContributor.completeReference(qualifier, qualifier, filter, true, true, parameters, qMatcher);
for (PsiClass aClass : PsiShortNamesCache.getInstance(qualifier.getProject()).getClassesByName(referenceName, qualifier.getResolveScope())) {
plainVariants.add(JavaClassNameCompletionContributor.createClassLookupItem(aClass, true));
}
if (!plainVariants.isEmpty()) {
return plainVariants;
}
final Set<LookupElement> allClasses = new LinkedHashSet<LookupElement>();
JavaClassNameCompletionContributor.addAllClasses(parameters.withPosition(qualifier.getReferenceNameElement(), qualifier.getTextRange().getEndOffset()),
true, qMatcher, new CollectConsumer<LookupElement>(allClasses));
return allClasses;
}
示例11: getReferenceFilter
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
@Nullable
private static ElementFilter getReferenceFilter(PsiElement element) {
//throw new foo
if (AFTER_THROW_NEW.accepts(element)) {
return new ElementExtractorFilter(THROWABLE_TYPE_FILTER);
}
//new xxx.yyy
if (psiElement().afterLeaf(psiElement().withText(".")).withSuperParent(2, psiElement(PsiNewExpression.class)).accepts(element)) {
if (((PsiNewExpression)element.getParent().getParent()).getClassReference() == element.getParent()) {
return new GeneratorFilter(AssignableGroupFilter.class, new ExpectedTypesGetter());
}
}
return null;
}
示例12: contributeMetaData
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
@Override
public void contributeMetaData(MetaDataRegistrar registrar) {
registrar.registerMetaData(new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag)element;
final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
if (domElement != null) {
return domElement.getGenericInfo().getNameDomElement(domElement) != null;
}
}
return false;
}
public boolean isClassAcceptable(Class hintClass) {
return XmlTag.class.isAssignableFrom(hintClass);
}
}, DomMetaData.class);
}
示例13: createTagCompletionFilter
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
protected ElementFilter createTagCompletionFilter() {
return new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
String name = ((XmlTag)context).getName();
if (element instanceof PsiElement &&
((PsiElement)element).getParent() == context) {
return true;
}
if (equalNames(name, STYLE_TAG) ||
equalNames(name,SCRIPT_TAG)) {
return false;
}
if ( isStyleAttributeContext((PsiElement)element) ) return false;
return true;
}
public boolean isClassAcceptable(Class hintClass) {
return true;
}
};
}
示例14: getIdForFilter
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
public ElementFilter getIdForFilter() {
return new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
final PsiElement grandParent = ((PsiElement)element).getParent().getParent();
if (grandParent instanceof XmlTag) {
final XmlTag tag = (XmlTag)grandParent;
if (tag.getNamespacePrefix().length() > 0) {
return true;
}
}
return false;
}
public boolean isClassAcceptable(Class hintClass) {
return true;
}
};
}
示例15: registerReferenceProviders
import com.intellij.psi.filters.ElementFilter; //导入依赖的package包/类
public void registerReferenceProviders(final PsiReferenceRegistrar registrar) {
final JavaClassListReferenceProvider classListProvider = new JavaClassListReferenceProvider();
registrar.registerReferenceProvider(xmlAttributeValue(), classListProvider, PsiReferenceRegistrar.LOWER_PRIORITY);
registrar.registerReferenceProvider(xmlTag(), classListProvider, PsiReferenceRegistrar.LOWER_PRIORITY);
final PsiReferenceProvider filePathReferenceProvider = new FilePathReferenceProvider();
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class).and(new FilterPattern(new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
PsiLiteralExpression literalExpression = (PsiLiteralExpression) context;
final Map<String, Object> annotationParams = new HashMap<String, Object>();
annotationParams.put(AnnotationUtil.PROPERTY_KEY_RESOURCE_BUNDLE_PARAMETER, null);
return !JavaI18nUtil.mustBePropertyKey(context.getProject(), literalExpression, annotationParams);
}
public boolean isClassAcceptable(Class hintClass) {
return true;
}
})), filePathReferenceProvider);
}