com.intellij.psi.search.searches.ClassInheritorsSearch Java Examples
The following examples show how to use
com.intellij.psi.search.searches.ClassInheritorsSearch.
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: JavaCamelIdeaUtils.java From camel-idea-plugin with Apache License 2.0 | 6 votes |
private List<PsiElement> findEndpoints(Module module, Predicate<String> uriCondition, Predicate<PsiLiteral> elementCondition) { PsiManager manager = PsiManager.getInstance(module.getProject()); //TODO: use IdeaUtils.ROUTE_BUILDER_OR_EXPRESSION_CLASS_QUALIFIED_NAME somehow PsiClass routeBuilderClass = ClassUtil.findPsiClass(manager, "org.apache.camel.builder.RouteBuilder"); List<PsiElement> results = new ArrayList<>(); if (routeBuilderClass != null) { Collection<PsiClass> routeBuilders = ClassInheritorsSearch.search(routeBuilderClass, module.getModuleScope(), true) .findAll(); for (PsiClass routeBuilder : routeBuilders) { Collection<PsiLiteralExpression> literals = PsiTreeUtil.findChildrenOfType(routeBuilder, PsiLiteralExpression.class); for (PsiLiteralExpression literal : literals) { Object val = literal.getValue(); if (val instanceof String) { String endpointUri = (String) val; if (uriCondition.test(endpointUri) && elementCondition.test(literal)) { results.add(literal); } } } } } return results; }
Example #2
Source File: ChangeHelper.java From MVPManager with MIT License | 5 votes |
public static void method(Project project, PsiJavaFile psiJavaFile, int type, MethodEntity methodEntity, boolean isDel) { for (PsiElement psiInterface : getClasses(psiJavaFile)) { if (psiInterface instanceof PsiClass) { switch (type) { case ChangeMVPDialog.VIEW: if (!ClassHelper.VIEW.equals(((PsiClass) psiInterface).getName())) continue; break; case ChangeMVPDialog.PRESENTER: if (!ClassHelper.PRESENTER.equals(((PsiClass) psiInterface).getName())) continue; break; case ChangeMVPDialog.MODEL: if (!ClassHelper.MODEL.equals(((PsiClass) psiInterface).getName())) continue; break; } if (isDel) { delMethod(project, psiInterface, methodEntity); } else { ClassHelper.addMethodToClass(project, (PsiClass) psiInterface, createList(methodEntity), false); } if (((PsiClass) psiInterface).getExtendsList() == null) return; // ClassInheritorsSearch query = ClassInheritorsSearch.search((PsiClass) psiInterface, true); Query<PsiClass> query = ClassInheritorsSearch.search((PsiClass) psiInterface); for (Iterator<PsiClass> it = query.iterator(); it.hasNext(); ) { PsiClass p = it.next(); if (isDel) { delMethod(project, p, methodEntity); } else { ClassHelper.addMethodToClass(project, p, createList(methodEntity), true); } } } } }
Example #3
Source File: SubclassTestChooser.java From intellij with Apache License 2.0 | 5 votes |
static List<PsiClass> findTestSubclasses(PsiClass testClass) { return ClassInheritorsSearch.search(testClass) .findAll() .stream() .filter(ProducerUtils::isTestClass) .collect(Collectors.toList()); }
Example #4
Source File: PullUpProcessor.java From intellij-haxe with Apache License 2.0 | 5 votes |
private void processMethodsDuplicates() { ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { if (!myTargetSuperClass.isValid()) return; final Query<PsiClass> search = ClassInheritorsSearch.search(myTargetSuperClass); final Set<VirtualFile> hierarchyFiles = new HashSet<VirtualFile>(); for (PsiClass aClass : search) { final PsiFile containingFile = aClass.getContainingFile(); if (containingFile != null) { final VirtualFile virtualFile = containingFile.getVirtualFile(); if (virtualFile != null) { hierarchyFiles.add(virtualFile); } } } final Set<PsiMember> methodsToSearchDuplicates = new HashSet<PsiMember>(); for (PsiMember psiMember : myMembersAfterMove) { if (psiMember instanceof PsiMethod && psiMember.isValid() && ((PsiMethod)psiMember).getBody() != null) { methodsToSearchDuplicates.add(psiMember); } } MethodDuplicatesHandler.invokeOnScope(myProject, methodsToSearchDuplicates, new AnalysisScope(myProject, hierarchyFiles), true); } }); } }, MethodDuplicatesHandler.REFACTORING_NAME, true, myProject); }