From 39a2ca4115d67ce700dafcb8fbc15c029f1123ed Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 18 May 2012 19:58:05 +0400 Subject: [PATCH] ability to create psitype with jvmfactory --- .../codeInsight/generation/GenerateMembersUtil.java | 2 +- .../src/com/intellij/psi/JVMElementFactory.java | 9 +++++++++ .../src/com/intellij/psi/PsiElementFactory.java | 8 -------- .../lang/psi/impl/GroovyPsiElementFactoryImpl.java | 6 ++++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java index 13f3d21348dd..337db3857199 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java @@ -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)))); } } }); diff --git a/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java b/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java index 3e6487879d67..ff2dcc2b1ec9 100644 --- a/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java +++ b/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java @@ -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); } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java index 333b7b9e94ab..c90c49489137 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java @@ -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. diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index eb22d3caf49b..f9a4f0e8e667 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -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() + ")")); }