com.intellij.psi.search.searches.AnnotatedElementsSearch Java Examples

The following examples show how to use com.intellij.psi.search.searches.AnnotatedElementsSearch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPropertiesProvider.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create a search pattern for the given <code>annotationName</code> annotation
 * name.
 * 
 * @param annotationName the annotation name to search.
 * @return a search pattern for the given <code>annotationName</code> annotation
 *         name.
 */
protected static Query<PsiModifierListOwner> createAnnotationTypeReferenceSearchPattern(SearchContext context, String annotationName) {
	PsiClass annotationClass = context.getUtils().findClass(context.getModule(), annotationName);
	if (annotationClass != null) {
		return AnnotatedElementsSearch.searchElements(annotationClass, context.getScope(), PsiModifierListOwner.class);
	} else {
		return new EmptyQuery<>();
	}
}
 
Example #2
Source File: JavaClassUtils.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Return a list of {@link PsiClass}s annotated with the specified annotation
 * @param project - Project reference to narrow the search inside.
 * @param annotation - the full qualify annotation name to search for
 * @return a list of classes annotated with the specified annotation.
 */
@NotNull
private Collection<PsiClass> getClassesAnnotatedWith(Project project, String annotation) {
    PsiClass stepClass = JavaPsiFacade.getInstance(project).findClass(annotation, ProjectScope.getLibrariesScope(project));
    if (stepClass != null) {
        final Query<PsiClass> psiMethods = AnnotatedElementsSearch.searchPsiClasses(stepClass, GlobalSearchScope.allScope(project));
        return psiMethods.findAll();
    }
    return Collections.emptyList();
}
 
Example #3
Source File: StepUtil.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
public static Collection<PsiMethod> getStepMethods(Module module) {
    final PsiClass step = JavaPsiFacade.getInstance(module.getProject()).findClass("com.thoughtworks.gauge.Step", 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<>();
}