From 051a2edc5ef8d0187e51fd566052fa67601d10f5 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 23 Sep 2016 12:40:37 +0300 Subject: [PATCH] ensure vars are created with denotable types; parameters are not covered yet as ellipsis are allowed there --- .../src/com/intellij/psi/impl/PsiElementFactoryImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java index d001c05693b0..85da19dde5a9 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java @@ -226,7 +226,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps throw new IncorrectOperationException("Cannot create field with type \"null\"."); } - @NonNls final String text = "class _Dummy_ { private " + type.getCanonicalText(true) + " " + name + "; }"; + @NonNls final String text = "class _Dummy_ { private " + GenericsUtil.getVariableTypeByExpressionType(type).getCanonicalText(true) + " " + name + "; }"; final PsiJavaFile aFile = createDummyJavaFile(text); final PsiClass[] classes = aFile.getClasses(); if (classes.length < 1) { @@ -250,7 +250,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps throw new IncorrectOperationException("Cannot create method with type \"null\"."); } - final String canonicalText = returnType.getCanonicalText(true); + final String canonicalText = GenericsUtil.getVariableTypeByExpressionType(returnType).getCanonicalText(true); final PsiJavaFile aFile = createDummyJavaFile("class _Dummy_ { public " + canonicalText + " " + name + "() {\n} }"); final PsiClass[] classes = aFile.getClasses(); if (classes.length < 1) { @@ -268,7 +268,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps @NotNull @Override public PsiMethod createMethod(@NotNull @NonNls String name, PsiType returnType, PsiElement context) throws IncorrectOperationException { - return createMethodFromText("public " + returnType.getCanonicalText(true) + " " + name + "() {}", context); + return createMethodFromText("public " + GenericsUtil.getVariableTypeByExpressionType(returnType).getCanonicalText(true) + " " + name + "() {}", context); } @NotNull