Exemplo n.º 1
0
 private void addTypeParams(PsiTypeParameterListOwner from, SNode to) {
   ListSequence.fromList(SLinkOperations.getTargets(to, "typeVariableDeclaration", true))
       .addSequence(
           Sequence.fromIterable(Sequence.fromArray(from.getTypeParameters()))
               .select(
                   new ISelector<PsiTypeParameter, SNode>() {
                     public SNode select(PsiTypeParameter it) {
                       return convertTypeParameter(it);
                     }
                   }));
 }
  private static PsiSubstitutor getRawingSubstitutor(PsiElement context, PsiClass targetClass) {
    if (context == null || targetClass == null) return PsiSubstitutor.EMPTY;

    PsiTypeParameterListOwner currContext =
        PsiTreeUtil.getParentOfType(context, PsiTypeParameterListOwner.class);
    PsiManager manager = context.getManager();
    PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
    while (currContext != null && !manager.areElementsEquivalent(currContext, targetClass)) {
      PsiTypeParameter[] typeParameters = currContext.getTypeParameters();
      substitutor =
          JavaPsiFacade.getInstance(context.getProject())
              .getElementFactory()
              .createRawSubstitutor(substitutor, typeParameters);
      currContext = currContext.getContainingClass();
    }

    return substitutor;
  }