diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMethodToClosureIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMethodToClosureIntention.java index 9a848c2aa45a..c5b071dd1c4d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMethodToClosureIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMethodToClosureIntention.java @@ -151,7 +151,7 @@ public class ConvertMethodToClosureIntention extends Intention { if (((GrMethod)parent).getNameIdentifierGroovy() != element) return false; method = (GrMethod)parent; } - return method.getBlock() != null && method.getParent() instanceof GrTypeDefinitionBody; + return !method.isConstructor() && method.getBlock() != null && method.getParent() instanceof GrTypeDefinitionBody; // return element instanceof GrMethod && ((GrMethod)element).getBlock() != null && element.getParent() instanceof GrTypeDefinitionBody; } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMethodToClosureTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMethodToClosureTest.java index 967b0877b8ef..83730fc4407f 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMethodToClosureTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMethodToClosureTest.java @@ -1,17 +1,17 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.jetbrains.plugins.groovy.intentions; @@ -63,12 +63,17 @@ public class ConvertMethodToClosureTest extends GrIntentionTestCase { doClosureToMethodTest(); } + public void testConstructorToClosure() { doMethodToClosureTest(false); } + private void doClosureToMethodTest() { doTest(GroovyIntentionsBundle.message("convert.closure.to.method.intention.name"), true); } private void doMethodToClosureTest() { - doTest(GroovyIntentionsBundle.message("convert.method.to.closure.intention.name"), true); + doMethodToClosureTest(true); } + private void doMethodToClosureTest(boolean available) { + doTest(GroovyIntentionsBundle.message("convert.method.to.closure.intention.name"), available); + } } diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/ConstructorToClosure.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/ConstructorToClosure.groovy new file mode 100644 index 000000000000..5aed7537e84b --- /dev/null +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/ConstructorToClosure.groovy @@ -0,0 +1,3 @@ +class Aa { + Aa(a) {} +} \ No newline at end of file