• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AnnotatedElementsSearch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.psi.search.searches.AnnotatedElementsSearch的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedElementsSearch类的具体用法?Java AnnotatedElementsSearch怎么用?Java AnnotatedElementsSearch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AnnotatedElementsSearch类属于com.intellij.psi.search.searches包,在下文中一共展示了AnnotatedElementsSearch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
    }
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:17,代码来源:CoffigResolver.java


示例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;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:19,代码来源:AnnotatedInterfaceNode.java


示例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;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:19,代码来源:ResourcesNode.java


示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:GroovyConstructorUsagesSearcher.java


示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:MetaAnnotationUtil.java


示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:MetaAnnotationUtil.java


示例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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:ClassesWithAnnotatedMembersSearcher.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:DataBindingUtil.java


示例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);
}
 
开发者ID:charlescapps,项目名称:robot-intellij-plugin,代码行数:12,代码来源:RobotJavaPsiUtil.java


示例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);
}
 
开发者ID:charlescapps,项目名称:robot-intellij-plugin,代码行数:14,代码来源:RobotJavaPsiUtil.java


示例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<>();
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:11,代码来源:StepUtil.java


示例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();
}
 
开发者ID:troger,项目名称:nuxeo-intellij,代码行数:8,代码来源:NuxeoHotReloader.java


示例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);
	}
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:9,代码来源:JamCommonUtil.java


示例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;
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:35,代码来源:ClassesWithAnnotatedMembersSearcher.java


示例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));
}
 
开发者ID:TNG,项目名称:jgiven-intellij-plugin,代码行数:5,代码来源:ScenarioStateReferenceProvider.java


示例16: execute

import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final AnnotatedElementsSearch.Parameters p, @NotNull final Processor<PsiModifierListOwner> consumer) {
  final PsiClass annClass = p.getAnnotationClass();
  assert annClass.isAnnotationType() : "Annotation type should be passed to annotated members search";

  final String annotationFQN = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return annClass.getQualifiedName();
    }
  });
  assert annotationFQN != null;

  final PsiManager psiManager = ApplicationManager.getApplication().runReadAction(new Computable<PsiManager>() {
    @Override
    public PsiManager compute() {
      return annClass.getManager();
    }
  });

  final SearchScope useScope = p.getScope();
  final Class<? extends PsiModifierListOwner>[] types = p.getTypes();

  for (final PsiAnnotation ann : getAnnotationCandidates(annClass, useScope)) {
    final PsiModifierListOwner candidate = ApplicationManager.getApplication().runReadAction(new Computable<PsiModifierListOwner>() {
      @Override
      public PsiModifierListOwner compute() {
        PsiElement parent = ann.getParent();
        if (!(parent instanceof PsiModifierList)) {
          return null; // Can be a PsiNameValuePair, if annotation is used to annotate annotation parameters
        }

        final PsiElement owner = parent.getParent();
        if (!isInstanceof(owner, types)) {
          return null;
        }

        final PsiJavaCodeReferenceElement ref = ann.getNameReferenceElement();
        if (ref == null || !psiManager.areElementsEquivalent(ref.resolve(), annClass)) {
          return null;
        }

        return (PsiModifierListOwner)owner;
      }
    });

    if (candidate != null && !consumer.process(candidate)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:AnnotatedElementsSearcher.java


示例17: execute

import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final AnnotatedElementsSearch.Parameters p, @NotNull final Processor<PsiModifierListOwner> consumer) {
  final PsiClass annClass = p.getAnnotationClass();
  assert annClass.isAnnotationType() : "Annotation type should be passed to annotated members search";

  final String annotationFQN = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return annClass.getQualifiedName();
    }
  });
  assert annotationFQN != null;

  final SearchScope scope = p.getScope();

  final List<PsiModifierListOwner> candidates;
  if (scope instanceof GlobalSearchScope) {
    candidates = getAnnotatedMemberCandidates(annClass, ((GlobalSearchScope)scope));
  }
  else {
    candidates = new ArrayList<PsiModifierListOwner>();
    for (final PsiElement element : ((LocalSearchScope)scope).getScope()) {
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          if (element instanceof GroovyPsiElement) {
            ((GroovyPsiElement)element).accept(new GroovyRecursiveElementVisitor() {
              @Override
              public void visitMethod(GrMethod method) {
                candidates.add(method);
              }

              @Override
              public void visitField(GrField field) {
                candidates.add(field);
              }
            });
          }
        }
      });
    }
  }

  for (final PsiModifierListOwner candidate : candidates) {
    boolean accepted = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>(){
      @Override
      public Boolean compute() {
        if (AnnotatedElementsSearcher.isInstanceof(candidate, p.getTypes())) {
          PsiModifierList list = candidate.getModifierList();
          if (list != null) {
            for (PsiAnnotation annotation : list.getAnnotations()) {
              if (annotationFQN.equals(annotation.getQualifiedName()) && !consumer.process(candidate)) {
                return false;
              }
            }
          }
        }
        return true;
      }
    });
    if (!accepted) return false;
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:66,代码来源:AnnotatedMembersSearcher.java


示例18: execute

import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final AnnotatedElementsSearch.Parameters p, @NotNull final Processor<PsiModifierListOwner> consumer) {
  final PsiClass annClass = p.getAnnotationClass();
  assert annClass.isAnnotationType() : "Annotation type should be passed to annotated members search";

  final String annotationFQN = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return annClass.getQualifiedName();
    }
  });
  assert annotationFQN != null;

  final PsiManagerImpl psiManager = (PsiManagerImpl)annClass.getManager();

  final SearchScope useScope = p.getScope();
  final Class<? extends PsiModifierListOwner>[] types = p.getTypes();

  for (final PsiAnnotation ann : getAnnotationCandidates(annClass, useScope)) {
    final PsiModifierListOwner candidate = ApplicationManager.getApplication().runReadAction(new Computable<PsiModifierListOwner>() {
      @Override
      public PsiModifierListOwner compute() {
        PsiElement parent = ann.getParent();
        if (!(parent instanceof PsiModifierList)) {
          return null; // Can be a PsiNameValuePair, if annotation is used to annotate annotation parameters
        }

        final PsiElement owner = parent.getParent();
        if (!isInstanceof(owner, types)) {
          return null;
        }

        final PsiJavaCodeReferenceElement ref = ann.getNameReferenceElement();
        if (ref == null || !psiManager.areElementsEquivalent(ref.resolve(), annClass)) {
          return null;
        }

        return (PsiModifierListOwner)owner;
      }
    });

    if (candidate != null && !consumer.process(candidate)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:49,代码来源:AnnotatedElementsSearcher.java


示例19: execute

import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
public boolean execute(@NotNull final AnnotatedElementsSearch.Parameters p, @NotNull final Processor<PsiModifierListOwner> consumer) {
  final PsiClass annClass = p.getAnnotationClass();
  assert annClass.isAnnotationType() : "Annotation type should be passed to annotated members search";

  AccessToken token = ReadAction.start();
  final String annotationFQN;
  try {
    annotationFQN = annClass.getQualifiedName();
  }
  finally {
    token.finish();
  }
  assert annotationFQN != null;

  final SearchScope scope = p.getScope();

  final List<PsiModifierListOwner> candidates;
  if (scope instanceof GlobalSearchScope) {
    candidates = getAnnotatedMemberCandidates(annClass, ((GlobalSearchScope)scope));
  } else {
    candidates = new ArrayList<PsiModifierListOwner>();
    for (PsiElement element : ((LocalSearchScope)scope).getScope()) {
      if (element instanceof GroovyPsiElement) {
        ((GroovyPsiElement)element).accept(new GroovyRecursiveElementVisitor() {
          public void visitMethod(GrMethod method) {
            candidates.add(method);
          }

          public void visitField(GrField field) {
            candidates.add(field);
          }
        });
      }
    }
  }

  for (PsiModifierListOwner candidate : candidates) {
    token = ReadAction.start();
    try {
      if (!AnnotatedElementsSearcher.isInstanceof(candidate, p.getTypes())) {
        continue;
      }

      PsiModifierList list = candidate.getModifierList();
      if (list != null) {
        for (PsiAnnotation annotation : list.getAnnotations()) {
          if (annotationFQN.equals(annotation.getQualifiedName()) && !consumer.process(candidate)) {
            return false;
          }
        }
      }
    }
    finally {
      token.finish();
    }
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:60,代码来源:AnnotatedMembersSearcher.java


示例20: execute

import com.intellij.psi.search.searches.AnnotatedElementsSearch; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final AnnotatedElementsSearch.Parameters p, @NotNull final Processor<PsiModifierListOwner> consumer)
{
	final PsiClass annClass = p.getAnnotationClass();
	assert annClass.isAnnotationType() : "Annotation type should be passed to annotated members search";

	final String annotationFQN = ApplicationManager.getApplication().runReadAction(new Computable<String>()
	{
		@Override
		public String compute()
		{
			return annClass.getQualifiedName();
		}
	});
	assert annotationFQN != null;

	final PsiManager psiManager = ApplicationManager.getApplication().runReadAction(new Computable<PsiManager>()
	{
		@Override
		public PsiManager compute()
		{
			return annClass.getManager();
		}
	});

	final SearchScope useScope = p.getScope();
	final Class<? extends PsiModifierListOwner>[] types = p.getTypes();

	for(final PsiAnnotation ann : getAnnotationCandidates(annClass, useScope))
	{
		final PsiModifierListOwner candidate = ApplicationManager.getApplication().runReadAction(new Computable<PsiModifierListOwner>()
		{
			@Override
			public PsiModifierListOwner compute()
			{
				PsiElement parent = ann.getParent();
				if(!(parent instanceof PsiModifierList))
				{
					return null; // Can be a PsiNameValuePair, if annotation is used to annotate annotation parameters
				}

				final PsiElement owner = parent.getParent();
				if(!isInstanceof(owner, types))
				{
					return null;
				}

				final PsiJavaCodeReferenceElement ref = ann.getNameReferenceElement();
				if(ref == null || !psiManager.areElementsEquivalent(ref.resolve(), annClass))
				{
					return null;
				}

				return (PsiModifierListOwner) owner;
			}
		});

		if(candidate != null && !consumer.process(candidate))
		{
			return false;
		}
	}

	return true;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:66,代码来源:AnnotatedElementsSearcher.java



注:本文中的com.intellij.psi.search.searches.AnnotatedElementsSearch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BulkWriteResult类代码示例发布时间:2022-05-22
下一篇:
Java EntityDescriptor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap