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

项目:camel-idea-plugin    文件:CamelDocumentationProvider.java   
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;
}
项目:lombok-intellij-plugin    文件:LombokLightClassBuilder.java   
public LombokLightClassBuilder withParameterTypes(@Nullable PsiTypeParameterList parameterList) {
  if (parameterList != null) {
    for (PsiTypeParameter typeParameter : parameterList.getTypeParameters()) {
      getTypeParameterList().addParameter(typeParameter);
    }
  }
  return this;
}
项目:lombok-intellij-plugin    文件:PsiMethodUtil.java   
@Nullable
public static PsiTypeParameterList createTypeParameterList(@NotNull PsiTypeParameterList psiTypeParameterList) {
  PsiTypeParameter[] psiTypeParameters = psiTypeParameterList.getTypeParameters();
  if (psiTypeParameters.length > 0) {

    final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiTypeParameterList.getProject());

    final StringBuilder builder = new StringBuilder("public <");

    for (PsiTypeParameter psiTypeParameter : psiTypeParameters) {
      builder.append(psiTypeParameter.getName());

      PsiClassType[] superTypes = psiTypeParameter.getExtendsListTypes();
      if (superTypes.length > 1 || superTypes.length == 1 && !superTypes[0].equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
        builder.append(" extends ");
        for (PsiClassType type : superTypes) {
          if (type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
            continue;
          }
          builder.append(type.getCanonicalText()).append('&');
        }
        builder.deleteCharAt(builder.length() - 1);
      }
      builder.append(',');
    }
    builder.deleteCharAt(builder.length() - 1);

    builder.append("> void foo(){}");

    PsiMethod methodFromText = elementFactory.createMethodFromText(builder.toString(), null);
    return methodFromText.getTypeParameterList();
  }
  return null;
}
项目:lombok-intellij-plugin    文件:BaseDelombokHandler.java   
private void rebuildTypeParameter(@NotNull PsiTypeParameterListOwner listOwner, @NotNull PsiTypeParameterListOwner resultOwner) {
  final PsiTypeParameterList fromMethodTypeParameterList = listOwner.getTypeParameterList();
  if (listOwner.hasTypeParameters() && null != fromMethodTypeParameterList) {
    PsiTypeParameterList typeParameterList = PsiMethodUtil.createTypeParameterList(fromMethodTypeParameterList);
    if (null != typeParameterList) {
      final PsiTypeParameterList resultOwnerTypeParameterList = resultOwner.getTypeParameterList();
      if (null != resultOwnerTypeParameterList) {
        resultOwnerTypeParameterList.replace(typeParameterList);
      }
    }
  }
}
项目:consulo-java    文件:MethodOrClassSelectioner.java   
private static Collection<TextRange> selectWithTypeParameters(@NotNull PsiClass psiClass) {
  final PsiIdentifier identifier = psiClass.getNameIdentifier();
  final PsiTypeParameterList list = psiClass.getTypeParameterList();
  if (identifier != null && list != null) {
    return Collections.singletonList(new TextRange(identifier.getTextRange().getStartOffset(), list.getTextRange().getEndOffset()));
  }
  return Collections.emptyList();
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitTypeParameterList(PsiTypeParameterList list) {
    mVisitor.report("PsiTypeParameterList", list.getText(), list);
    super.visitElement(list);
}
项目:intellij-ce-playground    文件:JavaTypeParameterListElementType.java   
@Override
public PsiTypeParameterList createPsi(@NotNull final PsiTypeParameterListStub stub) {
  return getPsiFactory(stub).createTypeParameterList(stub);
}
项目:intellij-ce-playground    文件:JavaTypeParameterListElementType.java   
@Override
public PsiTypeParameterList createPsi(@NotNull final ASTNode node) {
  return new PsiTypeParameterListImpl(node);
}
项目:intellij-ce-playground    文件:GrTypeParameterListOwner.java   
@Override
@Nullable
PsiTypeParameterList getTypeParameterList();
项目:tools-idea    文件:JavaTypeParameterListElementType.java   
@Override
public PsiTypeParameterList createPsi(@NotNull final PsiTypeParameterListStub stub) {
  return getPsiFactory(stub).createTypeParameterList(stub);
}
项目:tools-idea    文件:JavaTypeParameterListElementType.java   
@Override
public PsiTypeParameterList createPsi(@NotNull final ASTNode node) {
  return new PsiTypeParameterListImpl(node);
}
项目:tools-idea    文件:GrTypeParameterListOwner.java   
@Nullable
PsiTypeParameterList getTypeParameterList();
项目:consulo-java    文件:JavaTypeParameterListElementType.java   
@Override
public PsiTypeParameterList createPsi(@NotNull final PsiTypeParameterListStub stub) {
  return getPsiFactory(stub).createTypeParameterList(stub);
}
项目:consulo-java    文件:JavaTypeParameterListElementType.java   
@Override
public PsiTypeParameterList createPsi(@NotNull final ASTNode node) {
  return new PsiTypeParameterListImpl(node);
}