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() 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/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/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 +} ''') } } 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() }