ability to create psitype with jvmfactory

This commit is contained in:
Anna Kozlova
2012-05-18 19:59:14 +04:00
parent 51127d1b1c
commit 39a2ca4115
4 changed files with 16 additions and 9 deletions
@@ -320,7 +320,7 @@ public class GenerateMembersUtil {
super.visitReferenceElement(reference);
final PsiElement resolve = reference.resolve();
if (resolve instanceof PsiTypeParameter) {
replacementMap.put(reference, factory.createReferenceElementByType((PsiClassType)substitutor.substitute((PsiTypeParameter)resolve)));
replacementMap.put(reference, factory.createReferenceElementByType((PsiClassType)substituteType(substitutor, factory.createType((PsiTypeParameter)resolve))));
}
}
});
@@ -136,4 +136,13 @@ public interface JVMElementFactory {
@NotNull
PsiTypeParameter createTypeParameter(String name, PsiClassType[] superTypes);
/**
* Creates a class type for the specified class.
*
* @param aClass the class for which the class type is created.
* @return the class type instance.
*/
@NotNull
PsiClassType createType(@NotNull PsiClass aClass);
}
@@ -154,14 +154,6 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor
*/
@NotNull PsiCodeBlock createCodeBlock();
/**
* Creates a class type for the specified class.
*
* @param aClass the class for which the class type is created.
* @return the class type instance.
*/
@NotNull PsiClassType createType(@NotNull PsiClass aClass);
/**
* Creates a class type for the specified class, using the specified substitutor
* to replace generic type parameters on the class.
@@ -396,6 +396,12 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
return createTypeElement(typeText);
}
@NotNull
@Override
public PsiClassType createType(@NotNull PsiClass aClass) {
return JavaPsiFacade.getElementFactory(myProject).createType(aClass);
}
public GrParenthesizedExpression createParenthesizedExpr(GrExpression newExpr) {
return ((GrParenthesizedExpression) getInstance(myProject).createExpressionFromText("(" + newExpr.getText() + ")"));
}