类com.intellij.psi.PsiTypeParameterList源码实例Demo

下面列出了怎么用com.intellij.psi.PsiTypeParameterList的API类实例代码及写法,或者点击链接到github查看源代码。

private boolean isPsiMethodCamelLanguage(PsiMethod method) {
    PsiType type = method.getReturnType();
    if (type != null && type instanceof PsiClassReferenceType) {
        PsiClassReferenceType clazz = (PsiClassReferenceType) type;
        PsiClass resolved = clazz.resolve();
        if (resolved != null) {
            boolean language = getCamelIdeaUtils().isCamelExpressionOrLanguage(resolved);
            // try parent using some weird/nasty stub stuff which is how complex IDEA AST
            // is when its parsing the Camel route builder
            if (!language) {
                PsiElement elem = resolved.getParent();
                if (elem instanceof PsiTypeParameterList) {
                    elem = elem.getParent();
                }
                if (elem instanceof PsiClass) {
                    language = getCamelIdeaUtils().isCamelExpressionOrLanguage((PsiClass) elem);
                }
            }
            return language;
        }
    }

    return false;
}
 
源代码2 项目: aircon   文件: InvalidJsonGenericTypesDetector.java
@Override
protected void visitJsonConfigAnnotation(final UAnnotation node, final PsiClass jsonType, final int genericTypesCount) {
	final PsiTypeParameterList typeParameterList = jsonType.getTypeParameterList();
	final int expectedGenericTypesCount = typeParameterList != null ? typeParameterList.getTypeParameters().length : 0;
	if (expectedGenericTypesCount != genericTypesCount) {
		report(node, String.format(Locale.getDefault(), DESC_FORMAT, jsonType.getName(), expectedGenericTypesCount, genericTypesCount));
	}
}
 
public LombokLightClassBuilder withParameterTypes(@Nullable PsiTypeParameterList parameterList) {
  if (parameterList != null) {
    Stream.of(parameterList.getTypeParameters()).forEach(this::withParameterType);
  }
  return this;
}
 
 类所在包
 同包方法