Java Code Examples for com.intellij.psi.util.PsiTypesUtil#getPsiClass()
The following examples show how to use
com.intellij.psi.util.PsiTypesUtil#getPsiClass() .
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: IocBeanInterfaceLineMarkerProvider.java From NutzCodeInsight with Apache License 2.0 | 6 votes |
@Nullable @Override public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) { try { PsiField psiFiled = this.getPsiFiled(psiElement); PsiAnnotation psiAnnotation = this.getPsiAnnotation(psiFiled); if (psiFiled != null && psiAnnotation != null) { GlobalSearchScope moduleScope = psiElement.getResolveScope(); PsiTypeElementImpl psiTypeElement = this.getPsiTypeElement(psiAnnotation); PsiClass psiClass = PsiTypesUtil.getPsiClass(psiTypeElement.getType()); String name = psiClass.getName(); List<PsiElement> list = this.getImplListElements(name, psiClass.getQualifiedName(), psiElement, moduleScope); if (CollectionUtils.isNotEmpty(list)) { return new LineMarkerInfo<>(psiTypeElement, psiTypeElement.getTextRange(), icon, new FunctionTooltip(MessageFormat.format("快速跳转至 {0} 的 @IocBean 实现类", name)), new IocBeanInterfaceNavigationHandler(name, list), GutterIconRenderer.Alignment.LEFT); } } } catch (Exception e) { } return null; }
Example 2
Source File: PsiEventDeclarationsExtractor.java From litho with Apache License 2.0 | 5 votes |
static EventDeclarationModel getEventDeclarationModel( PsiClassObjectAccessExpression psiExpression) { PsiType valueType = psiExpression.getOperand().getType(); PsiClass valueClass = PsiTypesUtil.getPsiClass(valueType); return new EventDeclarationModel( PsiTypeUtils.guessClassName(valueType.getCanonicalText()), getReturnType(valueClass), getFields(valueClass), psiExpression); }
Example 3
Source File: PsiUtils.java From data-mediator with Apache License 2.0 | 5 votes |
/** * Checks that the given type is an implementer of the given canonicalName with the given typed parameters * * @param type what we're checking against * @param canonicalName the type must extend/implement this generic * @param canonicalParamNames the type that the generic(s) must be (in this order) * @return */ public static boolean isTypedClass(PsiType type, String canonicalName, String... canonicalParamNames) { PsiClass parameterClass = PsiTypesUtil.getPsiClass(type); if (parameterClass == null) { return false; } // This is a safe cast, for if parameterClass != null, the type was checked in PsiTypesUtil#getPsiClass(...) PsiClassType pct = (PsiClassType) type; // Main class name doesn't match; exit early if (!canonicalName.equals(parameterClass.getQualifiedName())) { return false; } List<PsiType> psiTypes = new ArrayList<PsiType>(pct.resolveGenerics().getSubstitutor().getSubstitutionMap().values()); for (int i = 0; i < canonicalParamNames.length; i++) { if (!isOfType(psiTypes.get(i), canonicalParamNames[i])) { return false; } } // Passed all screenings; must be a match! return true; }
Example 4
Source File: DelegateHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean validateRecursion(PsiType psiType, ProblemBuilder builder) { final PsiClass psiClass = PsiTypesUtil.getPsiClass(psiType); if (null != psiClass) { final DelegateAnnotationElementVisitor delegateAnnotationElementVisitor = new DelegateAnnotationElementVisitor(psiType, builder); psiClass.acceptChildren(delegateAnnotationElementVisitor); return delegateAnnotationElementVisitor.isValid(); } return true; }
Example 5
Source File: PsiUtils.java From android-parcelable-intellij-plugin with Apache License 2.0 | 5 votes |
/** * Checks that the given type is an implementer of the given canonicalName with the given typed parameters * * @param type what we're checking against * @param canonicalName the type must extend/implement this generic * @param canonicalParamNames the type that the generic(s) must be (in this order) * @return */ public static boolean isTypedClass(PsiType type, String canonicalName, String... canonicalParamNames) { PsiClass parameterClass = PsiTypesUtil.getPsiClass(type); if (parameterClass == null) { return false; } // This is a safe cast, for if parameterClass != null, the type was checked in PsiTypesUtil#getPsiClass(...) PsiClassType pct = (PsiClassType) type; // Main class name doesn't match; exit early if (!canonicalName.equals(parameterClass.getQualifiedName())) { return false; } List<PsiType> psiTypes = new ArrayList<PsiType>(pct.resolveGenerics().getSubstitutor().getSubstitutionMap().values()); for (int i = 0; i < canonicalParamNames.length; i++) { if (!isOfType(psiTypes.get(i), canonicalParamNames[i])) { return false; } } // Passed all screenings; must be a match! return true; }
Example 6
Source File: ElementUtils.java From aircon with MIT License | 4 votes |
public static String getQualifiedName(final PsiType type) { final PsiClass psiClass = PsiTypesUtil.getPsiClass(type); return psiClass != null ? psiClass.getQualifiedName() : JAVA_LANG_PACKAGE + type.getPresentableText(); }