From 647d32e457c661395f8e2138a8447f4e274cbf70 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 3 Jul 2013 18:12:09 +0400 Subject: [PATCH 1/3] turning off in-proc javac to avoid OOME --- build/scripts/common_tests.gant | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/common_tests.gant b/build/scripts/common_tests.gant index 466446b0bb92..b0676182a637 100644 --- a/build/scripts/common_tests.gant +++ b/build/scripts/common_tests.gant @@ -27,7 +27,7 @@ target(compile: "Compile project") { } loadProject() - projectBuilder.useInProcessJavac = true + projectBuilder.useInProcessJavac = false projectBuilder.targetFolder = out projectBuilder.cleanOutput() projectBuilder.buildAll() From 8284bd7436ce3cbd1dc5a9fb1f49ed2b531f7d72 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 3 Jul 2013 17:31:11 +0400 Subject: [PATCH 2/3] IDEA-109503 don't highlight enum constants as unassigned --- .../finalVar/GrFinalVariableAccessInspection.java | 2 ++ .../inspections/GrFinalVariableAccessTest.groovy | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java index e10a91e100ab..f988749f47a7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java @@ -36,6 +36,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction; import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction; @@ -277,6 +278,7 @@ public class GrFinalVariableAccessInspection extends BaseInspection { } private static boolean isFieldInitialized(@NotNull GrField field) { + if (field instanceof GrEnumConstant) return true; if (field.getInitializerGroovy() != null) return true; final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy index c2063c8d8ba8..564a7940fbf6 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy @@ -496,6 +496,16 @@ class Aaa { this.bar = p // this one is not reported } } +''') + } + + void testEnumConstants() { + testHighlighting('''\ +enum E { + abc, cde + + final int x +} ''') } } From 816ef9a932d1eabc0d53bde8bd536e1685925200 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 3 Jul 2013 18:21:51 +0400 Subject: [PATCH 3/3] IDEA-109312 Groovy extract method drops return type information --- .../groovy/refactoring/extract/InitialInfo.java | 6 +----- .../extract/method/ExtractMethodTest.groovy | 16 ++++++++++++++++ .../argsUsedOnlyInAnonymousClass.test | 4 ++-- .../extractMethod/argsUsedOnlyInClosure.test | 4 ++-- .../refactoring/extractMethod/closureIt.test | 4 ++-- .../extractMethod/noContextConflicts.test | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java index ce29074eccb1..e50e6d5ed0d1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java @@ -25,7 +25,6 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo; @@ -103,10 +102,7 @@ public class InitialInfo implements ExtractInfoHelper { } } else if (ExtractUtil.isSingleExpression(statements)) { - final GrStatement single = statements[0]; - if (!(single.getParent() instanceof GrCodeBlock)) { - outputType = ((GrExpression)single).getType(); - } + outputType = ((GrExpression)statements[0]).getType(); } else if (hasReturnValue) { assert returnStatements.size() > 0; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy index a1a333575fbe..cf167e024754 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy @@ -180,6 +180,22 @@ def foo() { private String testMethod() { return 'b' } +''') + } + + void testSingleExpressionAsReturnValue() { + doTest('''\ +int foo() { + 1 +} +''', '''\ +int foo() { + testMethod() +} + +private int testMethod() { + return 1 +} ''') } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test index 0857daf5c4db..64a3ac58ab87 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test @@ -10,8 +10,8 @@ def foo(b, c) { testMethod(b, c) } -private testMethod(b, c) { - [].each(new Closure(this, this) { +private ArrayList testMethod(b, c) { + return [].each(new Closure(this, this) { void call() { b.plus(c) } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test index 7ff5598dbdff..76d9bc113ba8 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test @@ -8,8 +8,8 @@ def foo(b, c) { testMethod(b, c) } -private testMethod(b, c) { - [].each { +private ArrayList testMethod(b, c) { + return [].each { b.plus(c) } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test index d612cce14f70..33009331cc16 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test @@ -6,6 +6,6 @@ def foo() { testMethod() } -private testMethod() { - [].collect { it } +private List testMethod() { + return [].collect { it } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test index 317529596792..23964f5dbf5d 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test @@ -19,7 +19,7 @@ class StringCategory { testMethod() } - private testMethod() { + private void testMethod() { use(StringCategory) { println "TeSt".lower() }