本文整理汇总了Java中com.intellij.psi.search.searches.AnnotatedElementsSearch类的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedElementsSearch类的具体用法?Java AnnotatedElementsSearch怎么用?Java AnnotatedElementsSearch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnnotatedElementsSearch类属于com.intellij.psi.search.searches包,在下文中一共展示了AnnotatedElementsSearch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classStream
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
Stream<PsiClass> classStream() {
if (context.isValid()) {
Stream<PsiClass> stream = StreamSupport.stream(
AnnotatedElementsSearch.searchPsiClasses(
context.getConfigAnnotationClass(),
GlobalSearchScope.allScope(context.getProject())).spliterator(),
false);
Predicate<PsiClass> filter = context.getFilter();
if (filter != null) {
stream = stream.filter(filter);
}
return stream;
} else {
return Stream.empty();
}
}
示例2: computeChildren
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
protected MultiMap<PsiFile, T> computeChildren(@Nullable PsiFile psiFile) {
MultiMap<PsiFile, T> children = new MultiMap<>();
Project project = getProject();
if (project != null) {
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
PsiClass serviceAnnotation = javaPsiFacade.findClass(getAnnotationQName(), GlobalSearchScope.allScope(project));
if (serviceAnnotation != null) {
AnnotatedElementsSearch.searchPsiClasses(serviceAnnotation, GlobalSearchScope.allScope(project)).forEach(psiClass -> {
if (psiClass.isInterface() && isSatisfying(psiClass)) {
children.putValue(psiClass.getContainingFile(), createChild(psiClass));
}
return true;
});
}
}
return children;
}
示例3: computeChildren
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
public MultiMap<PsiFile, ResourceNode> computeChildren(PsiFile psiFile) {
Project project = getProject();
MultiMap<PsiFile, ResourceNode> children = new MultiMap<>();
if (project != null) {
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
PsiClass pathAnnotation = javaPsiFacade.findClass(PATH_ANNOTATION, GlobalSearchScope.allScope(project));
if (pathAnnotation != null) {
AnnotatedElementsSearch.searchPsiClasses(pathAnnotation, GlobalSearchScope.allScope(project)).forEach(psiClass -> {
if (!psiClass.isInterface() && !NavigatorUtil.isAbstract(psiClass)) {
children.putValue(psiClass.getContainingFile(), new ResourceNode(ResourcesNode.this, pathAnnotation, psiClass));
}
return true;
});
}
}
return children;
}
示例4: calcGppScope
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
private static GlobalSearchScope calcGppScope(Project project) {
final GlobalSearchScope allScope = GlobalSearchScope.allScope(project);
final GlobalSearchScope maximal = GlobalSearchScope.getScopeRestrictedByFileTypes(allScope, GroovyFileType.GROOVY_FILE_TYPE);
GlobalSearchScope gppExtensions = new DelegatingGlobalSearchScope(maximal, "groovy.gpp") {
@Override
public boolean contains(VirtualFile file) {
return super.contains(file) && GppTypeConverter.isGppExtension(file.getExtension());
}
};
final PsiClass typed = JavaPsiFacade.getInstance(project).findClass(GppTypeConverter.GROOVY_LANG_TYPED, allScope);
if (typed != null) {
final Set<VirtualFile> files = new HashSet<VirtualFile>();
AnnotatedElementsSearch.searchElements(typed, maximal, PsiModifierListOwner.class).forEach(new Processor<PsiModifierListOwner>() {
@Override
public boolean process(PsiModifierListOwner occurrence) {
ContainerUtil.addIfNotNull(occurrence.getContainingFile().getVirtualFile(), files);
return true;
}
});
GlobalSearchScope withTypedAnno = GlobalSearchScope.filesScope(project, files);
return withTypedAnno.union(gppExtensions);
}
return gppExtensions;
}
示例5: getChildren
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
public static Set<PsiClass> getChildren(@NotNull PsiClass psiClass, @NotNull GlobalSearchScope scope)
{
if(AnnotationTargetUtil.findAnnotationTarget(psiClass, PsiAnnotation.TargetType.ANNOTATION_TYPE, PsiAnnotation.TargetType.TYPE) == null)
{
return Collections.emptySet();
}
String name = psiClass.getQualifiedName();
if(name == null)
{
return Collections.emptySet();
}
Set<PsiClass> result = new THashSet<>(HASHING_STRATEGY);
AnnotatedElementsSearch.searchPsiClasses(psiClass, scope).forEach(processorResult ->
{
if(processorResult.isAnnotationType())
{
result.add(processorResult);
}
return true;
});
return result;
}
示例6: getChildren
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
public static Set<PsiClass> getChildren(final PsiClass psiClass, final GlobalSearchScope scope)
{
if(AnnotationTargetUtil.findAnnotationTarget(psiClass, PsiAnnotation.TargetType.ANNOTATION_TYPE, PsiAnnotation.TargetType.TYPE) == null)
{
return Collections.emptySet();
}
final String name = psiClass.getQualifiedName();
if(name == null)
{
return Collections.emptySet();
}
final Set<PsiClass> result = new THashSet<>(HASHING_STRATEGY);
AnnotatedElementsSearch.searchPsiClasses(psiClass, scope).forEach(processorResult ->
{
if(processorResult.isAnnotationType())
{
result.add(processorResult);
}
return true;
});
return result;
}
示例7: processQuery
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
public void processQuery(@NotNull ClassesWithAnnotatedMembersSearch.Parameters queryParameters,
@NotNull final Processor<PsiClass> consumer) {
SearchScope scope = queryParameters.getScope();
for (QueryExecutor executor : Extensions.getExtensions(ClassesWithAnnotatedMembersSearch.EP_NAME)) {
if (executor instanceof ScopedQueryExecutor) {
scope = scope.intersectWith(GlobalSearchScope.notScope(((ScopedQueryExecutor) executor).getScope(queryParameters)));
}
}
final Set<PsiClass> processed = new HashSet<PsiClass>();
AnnotatedElementsSearch.searchPsiMembers(queryParameters.getAnnotationClass(), scope).forEach(new Processor<PsiMember>() {
@Override
public boolean process(PsiMember member) {
PsiClass psiClass;
AccessToken token = ReadAction.start();
try {
psiClass = member instanceof PsiClass ? (PsiClass)member : member.getContainingClass();
}
finally {
token.finish();
}
if (psiClass != null && processed.add(psiClass)) {
consumer.process(psiClass);
}
return true;
}
});
}
示例8: collectVariableNamesFromBindables
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
private Set<String> collectVariableNamesFromBindables() {
JavaPsiFacade facade = JavaPsiFacade.getInstance(myFacet.getModule().getProject());
PsiClass aClass = facade.findClass(BINDABLE_QUALIFIED_NAME, myFacet.getModule().getModuleWithDependenciesAndLibrariesScope(false));
if (aClass == null) {
return null;
}
//noinspection unchecked
final Collection<? extends PsiModifierListOwner> psiElements =
AnnotatedElementsSearch.searchElements(aClass, myFacet.getModule().getModuleScope(), PsiMethod.class, PsiField.class).findAll();
return BrUtil.collectIds(psiElements);
}
示例9: findAllJavaRobotKeywords
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
public static void findAllJavaRobotKeywords(Project project, List<PsiElement> results, boolean wrapPsiMethods) {
// Search for all methods annotated with @RobotKeyword
GlobalSearchScope allScope = ProjectScope.getAllScope(project);
PsiClass robotKeywordAnnotation = getRobotKeywordPsiClass(project);
if (robotKeywordAnnotation == null) {
return; // If @RobotKeyword isn't on the classpath, just return.
}
Query<PsiMethod> query = AnnotatedElementsSearch.searchPsiMethods(robotKeywordAnnotation, allScope);
Processor<PsiMethod> methodProcessor = new RobotJavaMethodProcessor(results, SearchType.FIND_ALL, Optional.<String>absent(), wrapPsiMethods);
query.forEach(methodProcessor);
}
示例10: findAllJavaRobotKeywordsStartingWith
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
public static void findAllJavaRobotKeywordsStartingWith(Project project, List<PsiElement> results, String startsWith, boolean wrapPsiMethods) {
// Search for all methods annotated with @RobotKeyword that start with the given text
GlobalSearchScope allScope = ProjectScope.getAllScope(project);
PsiClass robotKeywordAnnotation = getRobotKeywordPsiClass(project);
if (robotKeywordAnnotation == null) {
// If @RobotKeyword isn't on the classpath, fall back to using word index.
findAllJavaKeywordsStartingWithUsingWordIndex(project, results, startsWith, wrapPsiMethods);
return;
}
Query<PsiMethod> query = AnnotatedElementsSearch.searchPsiMethods(robotKeywordAnnotation, allScope);
Processor<PsiMethod> methodProcessor = new RobotJavaMethodProcessor(results, SearchType.STARTS_WITH, Optional.of(startsWith), wrapPsiMethods);
query.forEach(methodProcessor);
}
示例11: getStepMethods
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
public static Collection<PsiMethod> getStepMethods(Module module) {
final PsiClass step = JavaPsiFacade.getInstance(module.getProject()).findClass(STEP_ANNOTATION_QUALIFIER, GlobalSearchScope.allScope(module.getProject()));
if (step != null) {
Collection<PsiMethod> methods = new ArrayList<>();
for (Module m : Gauge.getSubModules(module))
methods.addAll(AnnotatedElementsSearch.searchPsiMethods(step, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(m, true)).findAll());
return methods;
}
return new ArrayList<>();
}
示例12: findSeamClasses
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
private Collection<PsiClass> findSeamClasses(PsiClass seamAnnotationClass,
Module module) {
GlobalSearchScope moduleContentRootSearchScope = ModuleContentRootSearchScope.moduleScope(module);
Query<PsiClass> query = AnnotatedElementsSearch.searchPsiClasses(
seamAnnotationClass, moduleContentRootSearchScope);
return query.findAll();
}
示例13: findAnnotatedElements
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
public static <T extends PsiModifierListOwner> void findAnnotatedElements(Class<T> elementClass, String annotationClass, PsiManager psiManager, GlobalSearchScope scope, Processor<T> processor)
{
final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(annotationClass, GlobalSearchScope.allScope(psiManager.getProject()));
if(aClass != null)
{
AnnotatedElementsSearch.searchElements(aClass, scope, elementClass).forEach(processor);
}
}
示例14: processQuery
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
public void processQuery(@NotNull ClassesWithAnnotatedMembersSearch.Parameters queryParameters, @NotNull final Processor<PsiClass> consumer)
{
SearchScope scope = queryParameters.getScope();
for(QueryExecutor executor : Extensions.getExtensions(ClassesWithAnnotatedMembersSearch.EP_NAME))
{
if(executor instanceof ScopedQueryExecutor)
{
scope = scope.intersectWith(GlobalSearchScope.notScope(((ScopedQueryExecutor) executor).getScope(queryParameters)));
}
}
final Set<PsiClass> processed = new HashSet<>();
AnnotatedElementsSearch.searchPsiMembers(queryParameters.getAnnotationClass(), scope).forEach(member ->
{
PsiClass psiClass;
AccessToken token = ReadAction.start();
try
{
psiClass = member instanceof PsiClass ? (PsiClass) member : member.getContainingClass();
}
finally
{
token.finish();
}
if(psiClass != null && processed.add(psiClass))
{
consumer.process(psiClass);
}
return true;
});
}
示例15: findPsiFields
import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
private void findPsiFields(Project project, GlobalSearchScope scope, Processor<PsiField> processor) {
getScenarioStateClasses(project)
.forEach(a -> AnnotatedElementsSearch.searchPsiFields(a, scope).forEach(processor));
}