From 30aeed34ac442cddf48c0665b6b9a916dacf141e Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Tue, 16 Oct 2012 12:22:33 +0400 Subject: [PATCH] EA-39830 - IOE: GroovyPsiElementFactoryImpl.createMethodFromText --- .../groovy/refactoring/extract/ExtractUtil.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java index a36eda322dad..de618575aaad 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java @@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.refactoring.extract; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.CommonClassNames; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiPrimitiveType; @@ -361,20 +362,21 @@ public class ExtractUtil { PsiType type = helper.getOutputType(); final PsiPrimitiveType outUnboxed = PsiPrimitiveType.getUnboxedType(type); if (outUnboxed != null) type = outUnboxed; + String typeText = forPresentation ? type.getPresentableText() : type.getCanonicalText(); String returnType = typeText == null || !helper.specifyType() ? "" : typeText; - if (returnType.length() == 0) { + + if (StringUtil.isEmptyOrSpaces(returnType) || "null".equals(returnType)) { if (modifier.length() == 0) { - typeText = "def "; + return "def "; } else { - typeText = ""; + return ""; } } else { - typeText = returnType + " "; + return returnType + " "; } - return typeText; } public static boolean isSingleExpression(GrStatement[] statements) {