Java Code Examples for com.intellij.psi.PsiClass#equals()
The following examples show how to use
com.intellij.psi.PsiClass#equals() .
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: JavaTestContextProvider.java From intellij with Apache License 2.0 | 6 votes |
@Nullable private static TestContext fromSelectedMethods(List<PsiMethod> selectedMethods) { // Sort so multiple configurations created with different selection orders are the same. selectedMethods.sort(Comparator.comparing(PsiMethod::getName)); PsiMethod firstMethod = selectedMethods.get(0); PsiClass containingClass = firstMethod.getContainingClass(); if (containingClass == null || containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) { return null; } for (PsiMethod method : selectedMethods) { if (!containingClass.equals(method.getContainingClass())) { return null; } } return fromClassAndMethods(containingClass, selectedMethods); }
Example 2
Source File: Decider.java From dagger-intellij-plugin with Apache License 2.0 | 6 votes |
@Override public boolean shouldShow(UsageTarget target, Usage usage) { PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement(); PsiField field = PsiConsultantImpl.findField(element); if (field != null // && PsiConsultantImpl.hasAnnotation(field, CLASS_INJECT) // && PsiConsultantImpl.hasQuailifierAnnotations(field, qualifierAnnotations) && PsiConsultantImpl.hasTypeParameters(field, typeParameters)) { return true; } PsiMethod method = PsiConsultantImpl.findMethod(element); if (method != null && (PsiConsultantImpl.hasAnnotation(method, CLASS_INJECT) || PsiConsultantImpl.hasAnnotation(method, CLASS_PROVIDES))) { for (PsiParameter parameter : method.getParameterList().getParameters()) { PsiClass parameterClass = PsiConsultantImpl.checkForLazyOrProvider(parameter); if (parameterClass.equals(returnType) && PsiConsultantImpl.hasQuailifierAnnotations( parameter, qualifierAnnotations) && PsiConsultantImpl.hasTypeParameters(parameter, typeParameters)) { return true; } } } return false; }
Example 3
Source File: PsiUtils.java From intellij-reference-diagram with Apache License 2.0 | 5 votes |
private static PsiElement getRootPsiElementWithStack(PsiClass psiClass, PsiElement psiElement, List<PsiElement> stack) { stack.add(psiElement); PsiElement parent = psiElement.getParent(); if (parent == null) { return null; } try { if (parent instanceof PsiMethod) { if (PsiUtils.classHasMethod(psiClass, (PsiMethod) parent)) { return parent; } } else if (parent instanceof PsiClassInitializer) { if (PsiUtils.classHasClassInitializer(psiClass, (PsiClassInitializer) parent)) { return parent; } } else if (parent instanceof PsiField) { if (PsiUtils.classHasField(psiClass, (PsiField) parent)) { return parent; } } else if (parent instanceof PsiClass) { if (psiClass.equals(((PsiClass) parent).getContainingClass())) { return parent; } } else if (parent instanceof PsiAnonymousClass) { if (((PsiAnonymousClass) parent).getContainingClass().equals(psiClass)) { return parent; } } } catch (Exception ex) { stack.add(parent); String preparedStack = prepareStack(stack); throw new IllegalStateException("Cannot get root element. Stack: " + preparedStack); } return getRootPsiElementWithStack(psiClass, parent, stack); }
Example 4
Source File: PsiConsultantImpl.java From dagger-intellij-plugin with Apache License 2.0 | 5 votes |
private static boolean isLazyOrProvider(PsiClass psiClass) { if (psiClass == null) { return false; } Project project = psiClass.getProject(); JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project); GlobalSearchScope globalSearchScope = GlobalSearchScope.allScope(project); PsiClass lazyClass = javaPsiFacade.findClass(CLASS_LAZY, globalSearchScope); PsiClass providerClass = javaPsiFacade.findClass(CLASS_PROVIDER, globalSearchScope); return psiClass.equals(lazyClass) || psiClass.equals(providerClass); }
Example 5
Source File: BusPostDecider.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
@Override public boolean shouldShow(Usage usage) { PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement(); PsiMethodCallExpression methodCall = PsiConsultantImpl.findMethodCall(element); if (methodCall != null) { PsiType[] expressionTypes = methodCall.getArgumentList().getExpressionTypes(); for (PsiType expressionType : expressionTypes) { PsiClass argumentEventClass = PsiConsultantImpl.getClass(expressionType); if (argumentEventClass.equals(this.eventClass)) { return true; } } } return false; }